Search in sources :

Example 1 with TransferInputStream

use of org.commonjava.maven.galley.util.TransferInputStream in project galley by Commonjava.

the class Transfer method openInputStream.

public InputStream openInputStream(final boolean fireEvents, final EventMetadata eventMetadata) throws IOException {
    provider.waitForReadUnlock(resource);
    try {
        InputStream stream = provider.openInputStream(resource);
        if (stream == null) {
            return null;
        }
        if (fireEvents) {
            stream = new TransferInputStream(stream, new FileAccessEvent(this, eventMetadata), fileEventManager);
        }
        stream = decorator == null ? stream : decorator.decorateRead(stream, this, eventMetadata);
        logger.trace("Returning stream: {} for transfer: {}", stream.getClass().getName(), this);
        return stream;
    } catch (final IOException e) {
        if (fireEvents) {
            fileEventManager.fire(new FileErrorEvent(this, e, eventMetadata));
        }
        throw e;
    }
}
Also used : TransferInputStream(org.commonjava.maven.galley.util.TransferInputStream) InputStream(java.io.InputStream) FileErrorEvent(org.commonjava.maven.galley.event.FileErrorEvent) IOException(java.io.IOException) FileAccessEvent(org.commonjava.maven.galley.event.FileAccessEvent) TransferInputStream(org.commonjava.maven.galley.util.TransferInputStream)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 FileAccessEvent (org.commonjava.maven.galley.event.FileAccessEvent)1 FileErrorEvent (org.commonjava.maven.galley.event.FileErrorEvent)1 TransferInputStream (org.commonjava.maven.galley.util.TransferInputStream)1