mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57480: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 57290: Merged V4.1-BUG-FIX (4.1.7) to V4.2-BUG-FIX (4.2.1) 57279: Fix for MNT-9801. I have very slightly refactored the configuration of thumbnails. Rather than inject system.thumbnail.generate into both CreateThumbnail- and UpdateThumbnailActionExecuter, I am now injecting it into the ThumbnailService centrally. I left the old injector methods for backwards compatibility, but deprecated them. Now all requests to create a thumbnail via the ScriptNode API pre-check that thumbnail generation is enabled. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61822 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -48,6 +48,10 @@
|
|||||||
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
||||||
<property name="ruleService" ref="ruleService"/>
|
<property name="ruleService" ref="ruleService"/>
|
||||||
<property name="transactionService" ref="TransactionService" />
|
<property name="transactionService" ref="TransactionService" />
|
||||||
|
<!-- Generate thumbnails at all? A false value turns generation off regardless of mimetype -->
|
||||||
|
<property name="thumbnailsEnabled">
|
||||||
|
<value>${system.thumbnail.generate}</value>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- This bean is responsible for the conversion of thumbnail definitions to
|
<!-- This bean is responsible for the conversion of thumbnail definitions to
|
||||||
@@ -243,10 +247,6 @@
|
|||||||
<property name="thumbnailService">
|
<property name="thumbnailService">
|
||||||
<ref bean="ThumbnailService" />
|
<ref bean="ThumbnailService" />
|
||||||
</property>
|
</property>
|
||||||
<!-- Generate thumbnails at all? A false value turns generation off regardless of mimetype -->
|
|
||||||
<property name="generateThumbnails">
|
|
||||||
<value>${system.thumbnail.generate}</value>
|
|
||||||
</property>
|
|
||||||
<property name="mimetypeMaxSourceSizeKBytes">
|
<property name="mimetypeMaxSourceSizeKBytes">
|
||||||
<ref bean="mimetypeMaxSourceSizeKBytes" />
|
<ref bean="mimetypeMaxSourceSizeKBytes" />
|
||||||
</property>
|
</property>
|
||||||
@@ -266,10 +266,6 @@
|
|||||||
<property name="thumbnailService">
|
<property name="thumbnailService">
|
||||||
<ref bean="ThumbnailService" />
|
<ref bean="ThumbnailService" />
|
||||||
</property>
|
</property>
|
||||||
<!-- Generate thumbnails at all? A false value turns generation off regardless of mimetype -->
|
|
||||||
<property name="generateThumbnails">
|
|
||||||
<value>${system.thumbnail.generate}</value>
|
|
||||||
</property>
|
|
||||||
<property name="mimetypeMaxSourceSizeKBytes">
|
<property name="mimetypeMaxSourceSizeKBytes">
|
||||||
<ref bean="mimetypeMaxSourceSizeKBytes" />
|
<ref bean="mimetypeMaxSourceSizeKBytes" />
|
||||||
</property>
|
</property>
|
||||||
|
@@ -2866,71 +2866,76 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
|||||||
*/
|
*/
|
||||||
public ScriptThumbnail createThumbnail(String thumbnailName, boolean async)
|
public ScriptThumbnail createThumbnail(String thumbnailName, boolean async)
|
||||||
{
|
{
|
||||||
|
final ThumbnailService thumbnailService = services.getThumbnailService();
|
||||||
|
|
||||||
ScriptThumbnail result = null;
|
ScriptThumbnail result = null;
|
||||||
|
|
||||||
// Use the thumbnail registy to get the details of the thumbail
|
// If thumbnail generation has been configured off, then don't bother with any of this.
|
||||||
ThumbnailRegistry registry = this.services.getThumbnailService().getThumbnailRegistry();
|
if ( thumbnailService.getThumbnailsEnabled())
|
||||||
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
|
|
||||||
if (details == null)
|
|
||||||
{
|
{
|
||||||
// Throw exception
|
// Use the thumbnail registy to get the details of the thumbail
|
||||||
throw new ScriptException("The thumbnail name '" + thumbnailName + "' is not registered");
|
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
|
||||||
}
|
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
|
||||||
|
if (details == null)
|
||||||
// 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) ||
|
|
||||||
!services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT).exists())
|
|
||||||
{
|
|
||||||
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
|
// Throw exception
|
||||||
NodeRef thumbnailNodeRef = this.services.getThumbnailService().createThumbnail(
|
throw new ScriptException("The thumbnail name '" + thumbnailName + "' is not registered");
|
||||||
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)
|
|
||||||
|
// 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) ||
|
||||||
|
!services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT).exists())
|
||||||
{
|
{
|
||||||
Throwable rootCause = e.getRootCause();
|
if (logger.isDebugEnabled())
|
||||||
if (rootCause instanceof UnimportantTransformException)
|
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
|
||||||
{
|
{
|
||||||
logger.debug("Unable to create thumbnail '" + details.getName() + "' as "+rootCause.getMessage());
|
// Create the thumbnail
|
||||||
return null;
|
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);
|
||||||
}
|
}
|
||||||
throw e;
|
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
|
||||||
|
{
|
||||||
|
Action action = ThumbnailHelper.createCreateThumbnailAction(details, services);
|
||||||
|
|
||||||
|
// Queue async creation of thumbnail
|
||||||
|
this.services.getActionService().executeAction(action, this.nodeRef, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Action action = ThumbnailHelper.createCreateThumbnailAction(details, services);
|
|
||||||
|
|
||||||
// Queue async creation of thumbnail
|
|
||||||
this.services.getActionService().executeAction(action, this.nodeRef, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,9 +58,6 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
/** Node Service */
|
/** Node Service */
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
/** Property turns on and off all thumbnail creation */
|
|
||||||
private boolean generateThumbnails = true;
|
|
||||||
|
|
||||||
// Size limitations (in KBytes) indexed by mimetype for thumbnail creation
|
// Size limitations (in KBytes) indexed by mimetype for thumbnail creation
|
||||||
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
|
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
|
||||||
|
|
||||||
@@ -101,10 +98,17 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
/**
|
/**
|
||||||
* Enable thumbnail creation at all regardless of mimetype.
|
* Enable thumbnail creation at all regardless of mimetype.
|
||||||
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
|
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
|
||||||
|
* @deprecated Use {@link ThumbnailServiceImpl#setThumbnailsEnabled(boolean)} instead.
|
||||||
*/
|
*/
|
||||||
public void setGenerateThumbnails(boolean generateThumbnails)
|
public void setGenerateThumbnails(boolean generateThumbnails)
|
||||||
{
|
{
|
||||||
this.generateThumbnails = generateThumbnails;
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Thumbnail generation is " +
|
||||||
|
(generateThumbnails ? "enabled" : "disabled") +
|
||||||
|
"via deprecated method in " + this.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
this.thumbnailService.setThumbnailsEnabled(generateThumbnails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +118,7 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
// Check if thumbnailing is generally disabled
|
// Check if thumbnailing is generally disabled
|
||||||
if (!generateThumbnails)
|
if (!thumbnailService.getThumbnailsEnabled())
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -91,6 +91,9 @@ public class ThumbnailServiceImpl implements ThumbnailService,
|
|||||||
/** Thumbnail registry */
|
/** Thumbnail registry */
|
||||||
private ThumbnailRegistry thumbnailRegistry;
|
private ThumbnailRegistry thumbnailRegistry;
|
||||||
|
|
||||||
|
/** Flag to enable/disable the generation of all thumbnails. */
|
||||||
|
private boolean thumbnailsEnabled;
|
||||||
|
|
||||||
/** Rendition service */
|
/** Rendition service */
|
||||||
private RenditionService renditionService;
|
private RenditionService renditionService;
|
||||||
|
|
||||||
@@ -148,6 +151,10 @@ public class ThumbnailServiceImpl implements ThumbnailService,
|
|||||||
this.thumbnailRegistry = thumbnailRegistry;
|
this.thumbnailRegistry = thumbnailRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void setThumbnailsEnabled(boolean thumbnailsEnabled) { this.thumbnailsEnabled = thumbnailsEnabled; }
|
||||||
|
|
||||||
|
@Override public boolean getThumbnailsEnabled() { return this.thumbnailsEnabled; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the policy component to listen for various events
|
* Set the policy component to listen for various events
|
||||||
* @since 3.5.0
|
* @since 3.5.0
|
||||||
|
@@ -62,9 +62,6 @@ public class UpdateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
/** Node Service */
|
/** Node Service */
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
/** Property turns on and off all thumbnail creation */
|
|
||||||
private boolean generateThumbnails = true;
|
|
||||||
|
|
||||||
// Size limitations indexed by mime type for thumbnail creation
|
// Size limitations indexed by mime type for thumbnail creation
|
||||||
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
|
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
|
||||||
|
|
||||||
@@ -115,10 +112,17 @@ public class UpdateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
/**
|
/**
|
||||||
* Enable thumbnail creation at all regardless of mimetype.
|
* Enable thumbnail creation at all regardless of mimetype.
|
||||||
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
|
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
|
||||||
|
* @deprecated Use {@link ThumbnailServiceImpl#setThumbnailsEnabled(boolean)} instead.
|
||||||
*/
|
*/
|
||||||
public void setGenerateThumbnails(boolean generateThumbnails)
|
public void setGenerateThumbnails(boolean generateThumbnails)
|
||||||
{
|
{
|
||||||
this.generateThumbnails = generateThumbnails;
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Thumbnail generation is " +
|
||||||
|
(generateThumbnails ? "enabled" : "disabled") +
|
||||||
|
"via deprecated method in " + this.getClass().getSimpleName());
|
||||||
|
}
|
||||||
|
this.thumbnailService.setThumbnailsEnabled(generateThumbnails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +132,7 @@ public class UpdateThumbnailActionExecuter extends ActionExecuterAbstractBase
|
|||||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||||
{
|
{
|
||||||
// Check if thumbnailing is generally disabled
|
// Check if thumbnailing is generally disabled
|
||||||
if (!generateThumbnails)
|
if (!thumbnailService.getThumbnailsEnabled())
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -148,4 +148,18 @@ public interface ThumbnailService
|
|||||||
*/
|
*/
|
||||||
@Auditable(parameters = {"sourceNode"})
|
@Auditable(parameters = {"sourceNode"})
|
||||||
Map<String, FailedThumbnailInfo> getFailedThumbnails(NodeRef sourceNode);
|
Map<String, FailedThumbnailInfo> getFailedThumbnails(NodeRef sourceNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method enables or disables the creation of all thumbnails by this service.
|
||||||
|
*
|
||||||
|
* @param thumbnailsEnabled <code>true</code> to enable all thumbnail creation (the default setting), or <code>false</code> to disable.
|
||||||
|
* @since 4.1.7
|
||||||
|
*/
|
||||||
|
void setThumbnailsEnabled(boolean thumbnailsEnabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method indicates whether thumbnail creation via this service has been globally enabled or disabled.
|
||||||
|
* @since 4.1.7
|
||||||
|
*/
|
||||||
|
boolean getThumbnailsEnabled();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user