use of org.alfresco.repo.thumbnail.ThumbnailRegistry in project alfresco-remote-api by Alfresco.
the class NodesImpl method requestRenditions.
private void requestRenditions(List<ThumbnailDefinition> thumbnailDefs, Node fileNode) {
if (thumbnailDefs != null) {
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
for (ThumbnailDefinition thumbnailDef : thumbnailDefs) {
NodeRef sourceNodeRef = fileNode.getNodeRef();
String mimeType = fileNode.getContent().getMimeType();
long size = fileNode.getContent().getSizeInBytes();
// Check if anything is currently available to generate thumbnails for the specified mimeType
if (!registry.isThumbnailDefinitionAvailable(null, mimeType, size, sourceNodeRef, thumbnailDef)) {
throw new InvalidArgumentException("Unable to create thumbnail '" + thumbnailDef.getName() + "' for " + mimeType + " as no transformer is currently available.");
}
Action action = ThumbnailHelper.createCreateThumbnailAction(thumbnailDef, sr);
// Queue async creation of thumbnail
actionService.executeAction(action, sourceNodeRef, true, true);
}
}
}
use of org.alfresco.repo.thumbnail.ThumbnailRegistry in project alfresco-remote-api by Alfresco.
the class NodesImpl method getThumbnailDefs.
private List<ThumbnailDefinition> getThumbnailDefs(Set<String> renditionNames) {
List<ThumbnailDefinition> thumbnailDefs = null;
if (renditionNames != null) {
// If thumbnail generation has been configured off, then don't bother.
if (!thumbnailService.getThumbnailsEnabled()) {
throw new DisabledServiceException("Thumbnail generation has been disabled.");
}
thumbnailDefs = new ArrayList<>(renditionNames.size());
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
for (String renditionName : renditionNames) {
// Use the thumbnail registry to get the details of the thumbnail
ThumbnailDefinition thumbnailDef = registry.getThumbnailDefinition(renditionName);
if (thumbnailDef == null) {
throw new NotFoundException(renditionName + " is not registered.");
}
thumbnailDefs.add(thumbnailDef);
}
}
return thumbnailDefs;
}
use of org.alfresco.repo.thumbnail.ThumbnailRegistry in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method createRendition.
@Override
public void createRendition(NodeRef nodeRef, Rendition rendition, boolean executeAsync, Parameters parameters) {
// If thumbnail generation has been configured off, then don't bother.
if (!thumbnailService.getThumbnailsEnabled()) {
throw new DisabledServiceException("Thumbnail generation has been disabled.");
}
final NodeRef sourceNodeRef = validateNode(nodeRef.getStoreRef(), nodeRef.getId());
final NodeRef renditionNodeRef = getRenditionByName(sourceNodeRef, rendition.getId(), parameters);
if (renditionNodeRef != null) {
throw new ConstraintViolatedException(rendition.getId() + " rendition already exists.");
}
// Use the thumbnail registry to get the details of the thumbnail
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
ThumbnailDefinition thumbnailDefinition = registry.getThumbnailDefinition(rendition.getId());
if (thumbnailDefinition == null) {
throw new NotFoundException(rendition.getId() + " is not registered.");
}
ContentData contentData = getContentData(sourceNodeRef, true);
// Check if anything is currently available to generate thumbnails for the specified mimeType
if (!registry.isThumbnailDefinitionAvailable(contentData.getContentUrl(), contentData.getMimetype(), contentData.getSize(), sourceNodeRef, thumbnailDefinition)) {
throw new InvalidArgumentException("Unable to create thumbnail '" + thumbnailDefinition.getName() + "' for " + contentData.getMimetype() + " as no transformer is currently available.");
}
Action action = ThumbnailHelper.createCreateThumbnailAction(thumbnailDefinition, serviceRegistry);
// Create thumbnail - or else queue for async creation
actionService.executeAction(action, sourceNodeRef, true, executeAsync);
}
Aggregations