Search in sources :

Example 1 with FileLockException

use of org.apache.archiva.common.filelock.FileLockException 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);
    }
}
Also used : FileLockException(org.apache.archiva.common.filelock.FileLockException) IndexWriter(org.apache.archiva.webdav.util.IndexWriter) FileLockTimeoutException(org.apache.archiva.common.filelock.FileLockTimeoutException) InputStream(java.io.InputStream) IOException(java.io.IOException) ActiveLock(org.apache.jackrabbit.webdav.lock.ActiveLock) Lock(org.apache.archiva.common.filelock.Lock)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 FileLockException (org.apache.archiva.common.filelock.FileLockException)1 FileLockTimeoutException (org.apache.archiva.common.filelock.FileLockTimeoutException)1 Lock (org.apache.archiva.common.filelock.Lock)1 IndexWriter (org.apache.archiva.webdav.util.IndexWriter)1 ActiveLock (org.apache.jackrabbit.webdav.lock.ActiveLock)1