use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class LegacySynchronousTransformClient method isSupported.
@Override
public boolean isSupported(String sourceMimetype, long sourceSizeInBytes, String contentUrl, String targetMimetype, Map<String, String> actualOptions, String transformName, NodeRef sourceNodeRef) {
String renditionName = TransformDefinition.convertToRenditionName(transformName);
TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, actualOptions);
transformationOptions.setSourceNodeRef(sourceNodeRef);
ContentTransformer legacyTransform = getTransformer(contentUrl, sourceMimetype, sourceSizeInBytes, targetMimetype, transformationOptions);
if (logger.isDebugEnabled()) {
logger.debug(TRANSFORM + renditionName + " from " + sourceMimetype + (legacyTransform == null ? " is unsupported" : " is supported"));
}
return legacyTransform != null;
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class LegacySynchronousTransformClient method transform.
@Override
public void transform(ContentReader reader, ContentWriter writer, Map<String, String> actualOptions, String transformName, NodeRef sourceNodeRef) {
String renditionName = TransformDefinition.convertToRenditionName(transformName);
try {
TransformationOptions options = converter.getTransformationOptions(renditionName, actualOptions);
options.setSourceNodeRef(sourceNodeRef);
if (null == reader || !reader.exists()) {
throw new IllegalArgumentException("sourceNodeRef " + sourceNodeRef + " has no content.");
}
if (logger.isDebugEnabled()) {
logger.debug(TRANSFORM + "requested " + renditionName);
}
// We don't obtain the Legacy transformer and then call its transform method as they unlike Local and
// Transform Service transforms automatically fail over to the next highest priority. This was not done
// for the newer transforms, as a fail over can always be defined and that makes it simpler to understand
// what is going on.
transform(reader, writer, options);
if (logger.isDebugEnabled()) {
logger.debug(TRANSFORM + "created " + renditionName);
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug(TRANSFORM + "failed " + renditionName, e);
}
throw e;
}
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class LegacyTransformServiceRegistry method findTransformerName.
@Override
public String findTransformerName(String sourceMimetype, long sourceSizeInBytes, String targetMimetype, Map<String, String> actualOptions, String renditionName) {
String name = null;
try {
TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, actualOptions);
List<ContentTransformer> transformers = legacySynchronousTransformClient.getActiveTransformers(sourceMimetype, sourceSizeInBytes, targetMimetype, transformationOptions);
if (!transformers.isEmpty()) {
name = legacySynchronousTransformClient.getName() + ":" + transformers.get(0).getName();
}
} catch (IllegalArgumentException ignore) {
// Typically if the mimetype is invalid.
}
return name;
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class LegacyTransformServiceRegistry method findMaxSize.
@Override
public long findMaxSize(String sourceMimetype, String targetMimetype, Map<String, String> options, String renditionName) {
// This message is not logged if placed in afterPropertiesSet
if (firstTime) {
firstTime = false;
transformerDebug.debug("Legacy transforms are " + (enabled ? "enabled" : "disabled"));
}
long maxSize = 0;
if (enabled) {
try {
TransformationOptions transformationOptions = converter.getTransformationOptions(renditionName, options);
maxSize = legacySynchronousTransformClient.getMaxSourceSizeBytes(sourceMimetype, targetMimetype, transformationOptions);
} catch (IllegalArgumentException ignore) {
// Typically if the mimetype is invalid.
}
}
return maxSize;
}
use of org.alfresco.service.cmr.repository.TransformationOptions in project alfresco-repository by Alfresco.
the class ImageMagickContentTransformerTest method testReliability.
public void testReliability() throws Exception {
if (!this.transformer.getWorker().isAvailable()) {
return;
}
boolean reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_IMAGE_GIF, -1, MimetypeMap.MIMETYPE_TEXT_PLAIN, new TransformationOptions());
assertEquals("Mimetype should not be supported", false, reliability);
reliability = transformer.isTransformable(MimetypeMap.MIMETYPE_IMAGE_GIF, -1, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions());
assertEquals("Mimetype should be supported", true, reliability);
}
Aggregations