@Test(expected = ContentNotFoundException.class) public void testReadWithNoContent() throws IOException { final ContentClaim claim = new StandardContentClaim(new StandardResourceClaim(claimManager, "container1", "section 1", "1", false), 0L); final InputStream in = repository.read(claim); in.close(); }
@Override public InputStream read(final ContentClaim claim) throws IOException { if (claim == null) { return new ByteArrayInputStream(new byte[0]); } final Path path = getPath(claim, true); final FileInputStream fis = new FileInputStream(path.toFile()); if (claim.getOffset() > 0L) { try { StreamUtils.skip(fis, claim.getOffset()); } catch (IOException ioe) { IOUtils.closeQuietly(fis); throw ioe; } } if (claim.getLength() >= 0) { return new LimitedInputStream(fis, claim.getLength()); } else { return fis; } }
FileSystemRepository implements ContentRepository { @Override public InputStream read(final ContentClaim claim) throws IOException { if (claim == null) { return new ByteArrayInputStream(new byte[0]); } final Path path = getPath(claim, true); final FileInputStream fis = new FileInputStream(path.toFile()); if (claim.getOffset() > 0L) { try { StreamUtils.skip(fis, claim.getOffset()); } catch (IOException ioe) { IOUtils.closeQuietly(fis); throw ioe; } } if (claim.getLength() >= 0) { return new LimitedInputStream(fis, claim.getLength()); } else { return fis; } } }
FileSystemRepository implements ContentRepository { @Override public InputStream read(final ContentClaim claim) throws IOException { if (claim == null) { return new ByteArrayInputStream(new byte[0]); } final Path path = getPath(claim, true); final FileInputStream fis = new FileInputStream(path.toFile()); if (claim.getOffset() > 0L) { try { StreamUtils.skip(fis, claim.getOffset()); } catch (IOException ioe) { IOUtils.closeQuietly(fis); throw ioe; } } if (claim.getLength() >= 0) { return new LimitedInputStream(fis, claim.getLength()); } else { return fis; } } FileSystemRepository();  FileSystemRepository(final NiFiProperties nifiProperties); }
FileSystemRepository implements ContentRepository { @Override public InputStream read(final ContentClaim claim) throws IOException { if (claim == null) { return new ByteArrayInputStream(new byte[0]); } final Path path = getPath(claim, true); final FileInputStream fis = new FileInputStream(path.toFile()); if (claim.getOffset() > 0L) { try { StreamUtils.skip(fis, claim.getOffset()); } catch (IOException ioe) { IOUtils.closeQuietly(fis); throw ioe; } } if (claim.getLength() >= 0) { return new LimitedInputStream(fis, claim.getLength()); } else { return fis; } } FileSystemRepository();  FileSystemRepository(final NiFiProperties nifiProperties); @Override void initialize(final ResourceClaimManager claimManager); @Override void shutdown(); @Override Set<String> getContainerNames(); @Override long getContainerCapacity(final String containerName); @Override long getContainerUsableSpace(String containerName); @Override String getContainerFileStoreName(final String containerName); @Override void cleanup(); @Override ContentClaim create(final boolean lossTolerant); @Override int incrementClaimaintCount(final ContentClaim claim); @Override int getClaimantCount(final ContentClaim claim); @Override int decrementClaimantCount(final ContentClaim claim); @Override boolean remove(final ContentClaim claim); @Override ContentClaim clone(final ContentClaim original, final boolean lossTolerant); @Override long merge(final Collection<ContentClaim> claims, final ContentClaim destination, final byte[] header, final byte[] footer, final byte[] demarcator); @Override long importFrom(final Path content, final ContentClaim claim); @Override long importFrom(final InputStream content, final ContentClaim claim); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append, final long offset, final long length); @Override long exportTo(final ContentClaim claim, final OutputStream destination); @Override long exportTo(final ContentClaim claim, final OutputStream destination, final long offset, final long length); @Override long size(final ContentClaim claim); @Override InputStream read(final ContentClaim claim); @Override OutputStream write(final ContentClaim claim); @Override void purge(); static Path getArchivePath(final Path contentClaimPath); @Override boolean isAccessible(final ContentClaim contentClaim); }
FileSystemRepository implements ContentRepository { @Override public InputStream read(final ContentClaim claim) throws IOException { if (claim == null) { return new ByteArrayInputStream(new byte[0]); } final Path path = getPath(claim, true); final FileInputStream fis = new FileInputStream(path.toFile()); if (claim.getOffset() > 0L) { try { StreamUtils.skip(fis, claim.getOffset()); } catch (IOException ioe) { IOUtils.closeQuietly(fis); throw ioe; } } if (claim.getLength() >= 0) { return new LimitedInputStream(fis, claim.getLength()); } else { return fis; } } FileSystemRepository();  FileSystemRepository(final NiFiProperties nifiProperties); @Override void initialize(final ResourceClaimManager claimManager); @Override void shutdown(); @Override Set<String> getContainerNames(); @Override long getContainerCapacity(final String containerName); @Override long getContainerUsableSpace(String containerName); @Override String getContainerFileStoreName(final String containerName); @Override void cleanup(); @Override ContentClaim create(final boolean lossTolerant); @Override int incrementClaimaintCount(final ContentClaim claim); @Override int getClaimantCount(final ContentClaim claim); @Override int decrementClaimantCount(final ContentClaim claim); @Override boolean remove(final ContentClaim claim); @Override ContentClaim clone(final ContentClaim original, final boolean lossTolerant); @Override long merge(final Collection<ContentClaim> claims, final ContentClaim destination, final byte[] header, final byte[] footer, final byte[] demarcator); @Override long importFrom(final Path content, final ContentClaim claim); @Override long importFrom(final InputStream content, final ContentClaim claim); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append); @Override long exportTo(final ContentClaim claim, final Path destination, final boolean append, final long offset, final long length); @Override long exportTo(final ContentClaim claim, final OutputStream destination); @Override long exportTo(final ContentClaim claim, final OutputStream destination, final long offset, final long length); @Override long size(final ContentClaim claim); @Override InputStream read(final ContentClaim claim); @Override OutputStream write(final ContentClaim claim); @Override void purge(); static Path getArchivePath(final Path contentClaimPath); @Override boolean isAccessible(final ContentClaim contentClaim); static final int SECTIONS_PER_CONTAINER; static final long MIN_CLEANUP_INTERVAL_MILLIS; static final String ARCHIVE_DIR_NAME; static final String APPENDABLE_CLAIM_LENGTH_CAP; static final Pattern MAX_ARCHIVE_SIZE_PATTERN; }