use of org.apache.archiva.common.filelock.Lock in project archiva by apache.
the class ArchivaDavResource method spool.
@Override
public void spool(OutputContext outputContext) throws IOException {
if (!isCollection()) {
outputContext.setContentLength(Files.size(localResource));
outputContext.setContentType(mimeTypes.getMimeType(localResource.getFileName().toString()));
}
try {
if (!isCollection() && outputContext.hasStream()) {
Lock lock = fileLockManager.readFileLock(localResource);
try (InputStream is = Files.newInputStream(lock.getFile())) {
IOUtils.copy(is, outputContext.getOutputStream());
}
} else if (outputContext.hasStream()) {
IndexWriter writer = new IndexWriter(this, localResource, logicalResource);
writer.write(outputContext);
}
} catch (FileLockException e) {
throw new IOException(e.getMessage(), e);
} catch (FileLockTimeoutException e) {
throw new IOException(e.getMessage(), e);
}
}
Aggregations