@Test public void testVersioning() throws Exception { final Host host = new Host(new SpectraProtocol() { @Override public Scheme getScheme() { return Scheme.http; } }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials( System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key") )); final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path container = new Path("cyberduck-versioning", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path folder = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(folder, null, new TransferStatus()); final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final byte[] content = RandomUtils.nextBytes(1000); final TransferStatus status = new TransferStatus().length(content.length); status.setChecksum(new CRC32ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final SpectraBulkService bulk = new SpectraBulkService(session); bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status), new DisabledConnectionCallback()); { final OutputStream out = new SpectraWriteFeature(session).write(test, status, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); } assertEquals(content.length, new SpectraAttributesFinderFeature(session).find(test).getSize()); bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status.exists(true)), new DisabledConnectionCallback()); { final OutputStream out = new SpectraWriteFeature(session).write(test, status.exists(true), new DisabledConnectionCallback()); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); } assertEquals(content.length, new SpectraAttributesFinderFeature(session).find(test).getSize()); final AttributedList<Path> list = new SpectraObjectListService(session).list(folder, new DisabledListProgressListener()); assertEquals(2, list.size()); for(Path f : list) { assertTrue(f.attributes().getMetadata().isEmpty()); } new SpectraDeleteFeature(session).delete(Arrays.asList(test, folder), new DisabledLoginCallback(), new Delete.DisabledCallback()); for(Path f : new SpectraObjectListService(session).list(folder, new DisabledListProgressListener())) { assertTrue(f.attributes().isDuplicate()); if(f.attributes().getSize() == 0L) { assertTrue(f.attributes().getMetadata().containsKey(SpectraVersioningFeature.KEY_REVERTABLE)); } else { assertTrue(f.attributes().getMetadata().isEmpty()); } } session.close(); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return this.list(directory, listener, preferences.getInteger("s3.listing.chunksize")); }
SpectraObjectListService extends S3AbstractListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return this.list(directory, listener, preferences.getInteger("s3.listing.chunksize")); } }
SpectraObjectListService extends S3AbstractListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return this.list(directory, listener, preferences.getInteger("s3.listing.chunksize")); } SpectraObjectListService(final SpectraSession session); }
SpectraObjectListService extends S3AbstractListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return this.list(directory, listener, preferences.getInteger("s3.listing.chunksize")); } SpectraObjectListService(final SpectraSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
SpectraObjectListService extends S3AbstractListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return this.list(directory, listener, preferences.getInteger("s3.listing.chunksize")); } SpectraObjectListService(final SpectraSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }