use of org.alfresco.repo.rendition2.RenditionDefinitionRegistry2 in project alfresco-repository by Alfresco.
the class ScriptNode method createThumbnail.
/**
* Creates a thumbnail for the content property of the node.
*
* The thumbnail name corresponds to pre-set thumbnail details stored in the
* repository.
*
* If the thumbnail is created asynchronously then the result will be null and creation
* of the thumbnail will occure at some point in the background.
*
* If foce param specified system.thumbnail.generate is ignoring. Could be used for preview creation
*
* @param thumbnailName the name of the thumbnail
* @param async indicates whether the thumbnail is create asynchronously or not
* @param force ignore system.thumbnail.generate=false
* @return ScriptThumbnail the newly create thumbnail node or null if async creation occures
*
* @deprecated The async flag in the method signature will not be applicable as all of
* the future transformations will be asynchronous
*/
@Deprecated
public ScriptThumbnail createThumbnail(String thumbnailName, boolean async, boolean force) {
final ThumbnailService thumbnailService = services.getThumbnailService();
ScriptThumbnail result = null;
// We need to create preview for node even if system.thumbnail.generate=false
if (force || thumbnailService.getThumbnailsEnabled()) {
// Use the thumbnail registy to get the details of the thumbail
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
if (details == null) {
// Throw exception
throw new ScriptException("The thumbnail name '" + thumbnailName + "' is not registered");
}
// If there's nothing currently registered to generate thumbnails for the
// specified mimetype, then log a message and bail out
String nodeMimeType = getMimetype();
Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
if (!ContentData.hasContent(contentData)) {
if (logger.isDebugEnabled())
logger.debug("Unable to create thumbnail '" + details.getName() + "' as there is no content");
return null;
}
if (!registry.isThumbnailDefinitionAvailable(contentData.getContentUrl(), nodeMimeType, getSize(), nodeRef, details)) {
logger.info("Unable to create thumbnail '" + details.getName() + "' for " + nodeMimeType + " as no transformer is currently available.");
return null;
}
// Have the thumbnail created
if (async == false) {
try {
// Create the thumbnail
NodeRef thumbnailNodeRef = thumbnailService.createThumbnail(this.nodeRef, ContentModel.PROP_CONTENT, details.getMimetype(), details.getTransformationOptions(), details.getName());
// Create the thumbnail script object
result = new ScriptThumbnail(thumbnailNodeRef, this.services, this.scope);
} catch (AlfrescoRuntimeException e) {
Throwable rootCause = e.getRootCause();
if (rootCause instanceof UnimportantTransformException) {
logger.debug("Unable to create thumbnail '" + details.getName() + "' as " + rootCause.getMessage());
return null;
}
throw e;
}
} else {
RenditionDefinition2 renditionDefinition = renditionDefinitionRegistry2.getRenditionDefinition(thumbnailName);
if (renditionDefinition != null) {
renditionService2.render(nodeRef, thumbnailName);
} else {
Action action = ThumbnailHelper.createCreateThumbnailAction(details, services);
// Queue async creation of thumbnail
this.services.getActionService().executeAction(action, this.nodeRef, true, true);
}
}
}
return result;
}
use of org.alfresco.repo.rendition2.RenditionDefinitionRegistry2 in project alfresco-repository by Alfresco.
the class ThumbnailRegistry method getEquivalentRenditionDefinition2.
private RenditionDefinition2 getEquivalentRenditionDefinition2(ThumbnailDefinition thumbnailDefinition) {
String renditionName = thumbnailDefinition.getName();
RenditionDefinition2 renditionDefinition = renditionDefinitionRegistry2.getRenditionDefinition(renditionName);
if (renditionDefinition != null) {
String thumbnailTargetMimetype = thumbnailDefinition.getMimetype();
String renditionTargetMimetype = renditionDefinition.getTargetMimetype();
if (!renditionTargetMimetype.equals(thumbnailTargetMimetype)) {
renditionDefinition = null;
}
}
return renditionDefinition;
}
use of org.alfresco.repo.rendition2.RenditionDefinitionRegistry2 in project alfresco-repository by Alfresco.
the class RenditionServiceImpl method getEquivalentRenditionDefinition2.
// Finds a RenditionDefinition2 with the same name (local part) and target mimetype.
private RenditionDefinition2 getEquivalentRenditionDefinition2(RenditionDefinition rendDefn) {
QName renditionQName = rendDefn.getRenditionName();
String renditionName = renditionQName.getLocalName();
RenditionDefinitionRegistry2 renditionDefinitionRegistry2 = renditionService2.getRenditionDefinitionRegistry2();
RenditionDefinition2 renditionDefinition2 = renditionDefinitionRegistry2.getRenditionDefinition(renditionName);
RenditionDefinition2 equivalentRenditionDefinition2 = null;
if (renditionDefinition2 != null) {
String targetMimetype = (String) rendDefn.getParameterValue(AbstractRenderingEngine.PARAM_MIME_TYPE);
String targetMimetype2 = renditionDefinition2.getTargetMimetype();
equivalentRenditionDefinition2 = targetMimetype.equals(targetMimetype2) ? renditionDefinition2 : null;
}
return equivalentRenditionDefinition2;
}
Aggregations