@Test public void testReadCloseReleaseEntity() throws Exception { final TransferStatus status = new TransferStatus(); final Path container = new Path(".ACCESS_LOGS", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("DFW"); final SwiftRegionService regionService = new SwiftRegionService(session); final CountingInputStream in = new CountingInputStream(new SwiftReadFeature(session, regionService).read(new Path(container, "/cdn.cyberduck.ch/2015/03/01/10/3b1d6998c430d58dace0c16e58aaf925.log.gz", EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback())); in.close(); assertEquals(0L, in.getByteCount(), 0L); }
@Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { status.setChecksum(Checksum.NONE); final Response response; if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); } } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); } return new HttpMethodReleaseInputStream(response.getResponse()); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Download {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, file); } }
SwiftReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { status.setChecksum(Checksum.NONE); final Response response; if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); } } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); } return new HttpMethodReleaseInputStream(response.getResponse()); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Download {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, file); } } }
SwiftReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { status.setChecksum(Checksum.NONE); final Response response; if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); } } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); } return new HttpMethodReleaseInputStream(response.getResponse()); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Download {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, file); } } SwiftReadFeature(final SwiftSession session, final SwiftRegionService regionService); }
SwiftReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { status.setChecksum(Checksum.NONE); final Response response; if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); } } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); } return new HttpMethodReleaseInputStream(response.getResponse()); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Download {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, file); } } SwiftReadFeature(final SwiftSession session, final SwiftRegionService regionService); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file); }
SwiftReadFeature implements Read { @Override public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { status.setChecksum(Checksum.NONE); final Response response; if(status.isAppend()) { final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); } } else { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); } return new HttpMethodReleaseInputStream(response.getResponse()); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Download {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, file); } } SwiftReadFeature(final SwiftSession session, final SwiftRegionService regionService); @Override InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback); @Override boolean offset(final Path file);  }