use of org.alfresco.repo.content.transform.AbstractContentTransformer2 in project alfresco-repository by Alfresco.
the class ContentTransformServiceAdaptor method wrapLocalTransformer.
private ContentTransformer wrapLocalTransformer(String sourceUrl, String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions transformationOptions) {
AbstractContentTransformer2 transformer = null;
Map<String, String> options = converter.getOptions(transformationOptions, null, null);
LocalTransform localTransform = localTransformServiceRegistryImpl.getLocalTransform(sourceMimetype, sourceSize, targetMimetype, options, null);
if (localTransform != null) {
transformer = new AbstractContentTransformer2() {
@Override
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws ContentIOException {
try {
transformInternal(reader, writer, transformationOptions);
} catch (Exception e) {
throw new ContentIOException(e.getMessage(), e);
}
}
@Override
protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions transformationOptions) throws Exception {
localTransform.transform(reader, writer, options, null, null);
}
@Override
public void register() {
}
@Override
public boolean isSupportedTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options) {
return true;
}
@Override
public boolean isTransformable(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) {
return true;
}
@Override
public boolean isTransformableMimetype(String sourceMimetype, String targetMimetype, TransformationOptions options) {
return true;
}
@Override
public boolean isTransformableSize(String sourceMimetype, long sourceSize, String targetMimetype, TransformationOptions options) {
return true;
}
@Override
public String getName() {
return "Wrapped<" + localTransformServiceRegistryImpl.findTransformerName(sourceMimetype, sourceSize, targetMimetype, options, null) + ">";
}
};
}
return transformer;
}
Aggregations