use of org.alfresco.service.cmr.repository.TransformationOptionPair.Action in project alfresco-repository by Alfresco.
the class AbstractContentReader method getContentInputStream.
/**
* @see Channels#newInputStream(java.nio.channels.ReadableByteChannel)
*/
public InputStream getContentInputStream() throws ContentIOException {
try {
ReadableByteChannel channel = getReadableChannel();
InputStream is = Channels.newInputStream(channel);
// If we have a timeout or read limit, intercept the calls.
if (limits != null) {
TransformationOptionPair time = limits.getTimePair();
TransformationOptionPair kBytes = limits.getKBytesPair();
long timeoutMs = time.getValue();
long readLimitBytes = kBytes.getValue() * 1024;
if (timeoutMs > 0 || readLimitBytes > 0) {
Action timeoutAction = time.getAction();
Action readLimitAction = kBytes.getAction();
is = new TimeSizeRestrictedInputStream(is, timeoutMs, timeoutAction, readLimitBytes, readLimitAction, transformerDebug);
}
}
is = new BufferedInputStream(is);
// done
return is;
} catch (Throwable e) {
throw new ContentIOException("Failed to open stream onto channel: \n" + " accessor: " + this, e);
}
}
Aggregations