@Ignore @Test public void testSPECTRA66() 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(new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)), "SPECTRA-67", EnumSet.of(Path.Type.directory)); final HashMap<TransferItem, TransferStatus> files = new HashMap<>(); for(int i = 1; i < 100; i++) { files.put(new TransferItem(new Path(container, String.format("test-%d.f", i), EnumSet.of(Path.Type.file))), new TransferStatus()); } final SpectraBulkService bulk = new SpectraBulkService(session); final Set<UUID> uuid = bulk.pre(Transfer.Type.download, files, new DisabledConnectionCallback()); assertNotNull(uuid); assertFalse(uuid.isEmpty()); assertEquals(1, uuid.size()); try { for(Map.Entry<TransferItem, TransferStatus> entry : files.entrySet()) { final InputStream in = new SpectraReadFeature(session).read(entry.getKey().remote, entry.getValue(), new DisabledConnectionCallback()); assertNotNull(in); IOUtils.closeQuietly(in); } } catch(RetriableAccessDeniedException e) { } session.close(); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<TransferStatus> chunks = bulk.query(Transfer.Type.download, file, status); chunks.sort(Comparator.comparingLong(TransferStatus::getOffset)); final List<LazyInputStream> streams = new ArrayList<>(); for(TransferStatus chunk : chunks) { final LazyInputStream in = new LazyInputStream(new LazyInputStream.OpenCallback() { @Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } }); streams.add(in); } return new SequenceInputStream(Collections.enumeration(streams)); }
SpectraReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<TransferStatus> chunks = bulk.query(Transfer.Type.download, file, status); chunks.sort(Comparator.comparingLong(TransferStatus::getOffset)); final List<LazyInputStream> streams = new ArrayList<>(); for(TransferStatus chunk : chunks) { final LazyInputStream in = new LazyInputStream(new LazyInputStream.OpenCallback() { @Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } }); streams.add(in); } return new SequenceInputStream(Collections.enumeration(streams)); } }
SpectraReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<TransferStatus> chunks = bulk.query(Transfer.Type.download, file, status); chunks.sort(Comparator.comparingLong(TransferStatus::getOffset)); final List<LazyInputStream> streams = new ArrayList<>(); for(TransferStatus chunk : chunks) { final LazyInputStream in = new LazyInputStream(new LazyInputStream.OpenCallback() { @Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } }); streams.add(in); } return new SequenceInputStream(Collections.enumeration(streams)); } SpectraReadFeature(final SpectraSession session);  SpectraReadFeature(final SpectraSession session, final SpectraBulkService bulk); }
SpectraReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<TransferStatus> chunks = bulk.query(Transfer.Type.download, file, status); chunks.sort(Comparator.comparingLong(TransferStatus::getOffset)); final List<LazyInputStream> streams = new ArrayList<>(); for(TransferStatus chunk : chunks) { final LazyInputStream in = new LazyInputStream(new LazyInputStream.OpenCallback() { @Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } }); streams.add(in); } return new SequenceInputStream(Collections.enumeration(streams)); } SpectraReadFeature(final SpectraSession session);  SpectraReadFeature(final SpectraSession session, final SpectraBulkService bulk); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file); }
SpectraReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final List<TransferStatus> chunks = bulk.query(Transfer.Type.download, file, status); chunks.sort(Comparator.comparingLong(TransferStatus::getOffset)); final List<LazyInputStream> streams = new ArrayList<>(); for(TransferStatus chunk : chunks) { final LazyInputStream in = new LazyInputStream(new LazyInputStream.OpenCallback() { @Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } }); streams.add(in); } return new SequenceInputStream(Collections.enumeration(streams)); } SpectraReadFeature(final SpectraSession session);  SpectraReadFeature(final SpectraSession session, final SpectraBulkService bulk); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file);  }