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:
Alan Davis
2014-02-11 20:46:44 +00:00
parent 57f7266e48
commit 0995ee2824
6 changed files with 103 additions and 73 deletions

View File

@@ -48,6 +48,10 @@
<property name="behaviourFilter" ref="policyBehaviourFilter" />
<property name="ruleService" ref="ruleService"/>
<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>
<!-- This bean is responsible for the conversion of thumbnail definitions to
@@ -243,10 +247,6 @@
<property name="thumbnailService">
<ref bean="ThumbnailService" />
</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">
<ref bean="mimetypeMaxSourceSizeKBytes" />
</property>
@@ -266,10 +266,6 @@
<property name="thumbnailService">
<ref bean="ThumbnailService" />
</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">
<ref bean="mimetypeMaxSourceSizeKBytes" />
</property>

View File

@@ -2866,10 +2866,15 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
*/
public ScriptThumbnail createThumbnail(String thumbnailName, boolean async)
{
final ThumbnailService thumbnailService = services.getThumbnailService();
ScriptThumbnail result = null;
// If thumbnail generation has been configured off, then don't bother with any of this.
if ( thumbnailService.getThumbnailsEnabled())
{
// Use the thumbnail registy to get the details of the thumbail
ThumbnailRegistry registry = this.services.getThumbnailService().getThumbnailRegistry();
ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
if (details == null)
{
@@ -2902,7 +2907,7 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
try
{
// Create the thumbnail
NodeRef thumbnailNodeRef = this.services.getThumbnailService().createThumbnail(
NodeRef thumbnailNodeRef = thumbnailService.createThumbnail(
this.nodeRef,
ContentModel.PROP_CONTENT,
details.getMimetype(),
@@ -2930,7 +2935,7 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
// Queue async creation of thumbnail
this.services.getActionService().executeAction(action, this.nodeRef, true, true);
}
}
return result;
}

View File

@@ -58,9 +58,6 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
/** Node Service */
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
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
@@ -101,10 +98,17 @@ public class CreateThumbnailActionExecuter extends ActionExecuterAbstractBase
/**
* Enable thumbnail creation at all regardless of mimetype.
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
* @deprecated Use {@link ThumbnailServiceImpl#setThumbnailsEnabled(boolean)} instead.
*/
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)
{
// Check if thumbnailing is generally disabled
if (!generateThumbnails)
if (!thumbnailService.getThumbnailsEnabled())
{
if (logger.isDebugEnabled())
{

View File

@@ -91,6 +91,9 @@ public class ThumbnailServiceImpl implements ThumbnailService,
/** Thumbnail registry */
private ThumbnailRegistry thumbnailRegistry;
/** Flag to enable/disable the generation of all thumbnails. */
private boolean thumbnailsEnabled;
/** Rendition service */
private RenditionService renditionService;
@@ -148,6 +151,10 @@ public class ThumbnailServiceImpl implements ThumbnailService,
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
* @since 3.5.0

View File

@@ -62,9 +62,6 @@ public class UpdateThumbnailActionExecuter extends ActionExecuterAbstractBase
/** Node Service */
private NodeService nodeService;
/** Property turns on and off all thumbnail creation */
private boolean generateThumbnails = true;
// Size limitations indexed by mime type for thumbnail creation
private HashMap<String,Long> mimetypeMaxSourceSizeKBytes;
@@ -115,10 +112,17 @@ public class UpdateThumbnailActionExecuter extends ActionExecuterAbstractBase
/**
* Enable thumbnail creation at all regardless of mimetype.
* @param generateThumbnails a {@code false} value turns off all thumbnail creation.
* @deprecated Use {@link ThumbnailServiceImpl#setThumbnailsEnabled(boolean)} instead.
*/
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)
{
// Check if thumbnailing is generally disabled
if (!generateThumbnails)
if (!thumbnailService.getThumbnailsEnabled())
{
if (logger.isDebugEnabled())
{

View File

@@ -148,4 +148,18 @@ public interface ThumbnailService
*/
@Auditable(parameters = {"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();
}