Search in sources :

Example 1 with AbstractContentReader

use of org.alfresco.repo.content.AbstractContentReader in project alfresco-repository by Alfresco.

the class AbstractContentTransformerLimits method setReaderLimits.

/**
 * Pass on any limits to the reader. Will only do so if the reader is an
 * {@link AbstractContentReader}.
 * @param reader passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}.
 * @param writer passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}.
 * @param options passed to {@link #transform(ContentReader, ContentWriter, TransformationOptions)}.
 */
protected void setReaderLimits(ContentReader reader, ContentWriter writer, TransformationOptions options) {
    if (reader instanceof AbstractContentReader) {
        AbstractContentReader abstractContentReader = (AbstractContentReader) reader;
        TransformationOptionLimits limits = getLimits(reader, writer, options);
        abstractContentReader.setLimits(limits);
        abstractContentReader.setTransformerDebug(transformerDebug);
    }
}
Also used : TransformationOptionLimits(org.alfresco.service.cmr.repository.TransformationOptionLimits) AbstractContentReader(org.alfresco.repo.content.AbstractContentReader)

Example 2 with AbstractContentReader

use of org.alfresco.repo.content.AbstractContentReader in project alfresco-repository by Alfresco.

the class AbstractContentTransformerLimitsTest method testSetReaderLimits.

@Test
public void testSetReaderLimits() throws Exception {
    AbstractContentReader reader = new DummyAbstractContentReader(0, 0);
    long value = 1234;
    transformer.setTimeoutMs(value);
    transformer.register();
    assertEquals("Limit should not have been set in the reader", null, reader.getLimits());
    transformer.setReaderLimits(reader, null, options);
    assertEquals("Limit should have been set in the reader", value, reader.getLimits().getTimeoutMs());
    options.setTimeoutMs(--value);
    transformer.setReaderLimits(reader, null, options);
    assertEquals("Limit should have been set in the reader", value, reader.getLimits().getTimeoutMs());
}
Also used : AbstractContentReader(org.alfresco.repo.content.AbstractContentReader) Test(org.junit.Test)

Aggregations

AbstractContentReader (org.alfresco.repo.content.AbstractContentReader)2 TransformationOptionLimits (org.alfresco.service.cmr.repository.TransformationOptionLimits)1 Test (org.junit.Test)1