use of org.commonjava.maven.galley.util.TransferOutputStream in project galley by Commonjava.
the class Transfer method openOutputStream.
public OutputStream openOutputStream(final TransferOperation accessType, final boolean fireEvents, final EventMetadata eventMetadata) throws IOException {
provider.waitForWriteUnlock(resource);
try {
provider.lockWrite(resource);
OutputStream stream = provider.openOutputStream(resource);
if (stream == null) {
return null;
}
final TransferUnlocker unlocker = new TransferUnlocker(resource, provider);
if (fireEvents) {
logger.info("Wrapping output stream to: {} using event metadata: {}", this, eventMetadata);
stream = new TransferOutputStream(stream, unlocker, new FileStorageEvent(accessType, this, eventMetadata), fileEventManager);
} else {
logger.info("Wrapping output stream to: {} WITHOUT event metadata", this);
stream = new TransferOutputStream(stream, unlocker);
}
stream = decorator == null ? stream : decorator.decorateWrite(stream, this, accessType, eventMetadata);
return stream;
} catch (final IOException e) {
if (fireEvents) {
fileEventManager.fire(new FileErrorEvent(this, e, eventMetadata));
}
throw e;
}
}
Aggregations