private OutputStream registerStream(final ContentClaim contentClaim) throws IOException { final OutputStream out = contentRepo.write(contentClaim); final OutputStream buffered = new BufferedOutputStream(out, bufferSize); streamMap.put(contentClaim.getResourceClaim(), buffered); return buffered; }
private void redirect() throws IOException { final ContentRepository backupRepo = getBackupRepository(); if (backupRepo == null) { throw new IOException("Content Repository is out of space"); } final ContentClaim backupClaim = backupRepo.create(true); backupRepoClaimMap.put(claim, backupClaim); out = backupRepo.write(backupClaim); amos.writeTo(out); amos.destroy(); amos = null; }
@Override public ContentClaim clone(final ContentClaim original, final boolean lossTolerant) throws IOException { final ContentClaim createdClaim = create(lossTolerant); try (final InputStream dataIn = read(original)) { final ContentRepository createdClaimRepo = lossTolerant ? this : getBackupRepository(); if (createdClaimRepo == null) { throw new IllegalStateException("Cannot create non-loss-tolerant ContentClaim because there is no persistent Content Repository configured"); } try (final OutputStream dataOut = createdClaimRepo.write(createdClaim)) { StreamUtils.copy(dataIn, dataOut); } } return createdClaim; }
@Override public OutputStream write(final ContentClaim claim) throws IOException { final ContentClaim backupClaim = getBackupClaim(claim); return backupClaim == null ? getContent(claim).write() : getBackupRepository().write(backupClaim); }
if (contentClaim == null) { contentClaim = contentRepository.create(false); contentClaimOut = contentRepository.write(contentClaim);
try (final OutputStream rawOut = contentRepo.write(newClaim); final OutputStream out = new BufferedOutputStream(rawOut)) {
claimLog.debug("Creating ContentClaim {} for 'append' for {}", newClaim, source); final OutputStream rawOutStream = context.getContentRepository().write(newClaim); final OutputStream bufferedOutStream = new BufferedOutputStream(rawOutStream); outStream = new ByteCountingOutputStream(bufferedOutStream);