From 42390dfd1b0c4cfbdd762f6b11a700660271261b Mon Sep 17 00:00:00 2001 From: Neil McErlean Date: Thu, 22 Apr 2010 14:40:10 +0000 Subject: [PATCH] Fix for ALF-2047. The fix was to ensure that rendition definitions that produce thumbnails always have PARAM_RENDITION_NODETYPE=cm:thumbnail. To do this, I removed the parameter from the create thumbnail code and added it to the ThumbnailRenditionConvertor, from where it will be picked up by all the code that needs it. Formerly, the parameter was only set for create thumbnail calls, but not for update thumbnail calls. Therefore when the content nodes were changed as described in the issue, the updated thumbnails were of the default type in the rendition service, which is cm:content which leads to problems in various views. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19955 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/thumbnail/ThumbnailRenditionConvertor.java | 6 ++++++ .../org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java | 1 - .../alfresco/repo/thumbnail/ThumbnailServiceImplTest.java | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailRenditionConvertor.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailRenditionConvertor.java index 235914b22d..88071a4dd4 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailRenditionConvertor.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailRenditionConvertor.java @@ -22,6 +22,7 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import org.alfresco.model.ContentModel; import org.alfresco.repo.content.transform.magick.ImageResizeOptions; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; import org.alfresco.repo.content.transform.swf.SWFTransformationOptions; @@ -130,7 +131,12 @@ public class ThumbnailRenditionConvertor { Map parameters = new HashMap(); + // All TransformationOptions-based renditions are considered to be "thumbnails". + // Therefore they should be created with a node type of cm:thumbnail + parameters.put(RenditionService.PARAM_RENDITION_NODETYPE, ContentModel.TYPE_THUMBNAIL); + // parameters common to all transformations + putParameterIfNotNull(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, transformationOptions.getSourceContentProperty(), parameters); putParameterIfNotNull(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, transformationOptions.getTargetContentProperty(), parameters); putParameterIfNotNull(RenditionService.PARAM_DESTINATION_NODE, transformationOptions.getTargetNodeRef(), parameters); diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java index df4641cc57..6ef22c9c8d 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java @@ -430,7 +430,6 @@ public class ThumbnailServiceImpl implements ThumbnailService // Add the other parameters given in this method signature. params.put(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, contentProperty); params.put(AbstractRenderingEngine.PARAM_MIME_TYPE, mimetype); - params.put(RenditionService.PARAM_RENDITION_NODETYPE, ContentModel.TYPE_THUMBNAIL); // Set the parameters on the rendition definition. definition.addParameterValues(params); diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java index 3f4f6de73a..7ad7e3116e 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java @@ -261,8 +261,14 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, MimetypeMap.MIMETYPE_IMAGE_JPEG, imageTransformationOptions, "small"); + // Thumbnails should always be of type cm:thumbnail. + assertEquals(ContentModel.TYPE_THUMBNAIL, nodeService.getType(thumbnail1)); + // Update the thumbnail this.thumbnailService.updateThumbnail(thumbnail1, imageTransformationOptions); + + // ALF-2047. Thumbnails were changing to type cm:content after update. + assertEquals(ContentModel.TYPE_THUMBNAIL, nodeService.getType(thumbnail1)); } public void testGetThumbnailByName() throws Exception