@Test(expected = NotfoundException.class) public void testReadNotFound() 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 TransferStatus status = new TransferStatus(); final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, "nosuchname", EnumSet.of(Path.Type.file)); new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(test), status), new DisabledConnectionCallback()); new SpectraReadFeature(session).read(test, status, new DisabledConnectionCallback()); }
@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);  }