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
This commit is contained in:
Neil McErlean
2010-04-22 14:40:10 +00:00
parent c3e0afa696
commit 42390dfd1b
3 changed files with 12 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.transform.magick.ImageResizeOptions; import org.alfresco.repo.content.transform.magick.ImageResizeOptions;
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
import org.alfresco.repo.content.transform.swf.SWFTransformationOptions; import org.alfresco.repo.content.transform.swf.SWFTransformationOptions;
@@ -130,7 +131,12 @@ public class ThumbnailRenditionConvertor
{ {
Map<String, Serializable> parameters = new HashMap<String, Serializable>(); Map<String, Serializable> parameters = new HashMap<String, Serializable>();
// 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 // parameters common to all transformations
putParameterIfNotNull(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, transformationOptions.getSourceContentProperty(), parameters); putParameterIfNotNull(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, transformationOptions.getSourceContentProperty(), parameters);
putParameterIfNotNull(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, transformationOptions.getTargetContentProperty(), parameters); putParameterIfNotNull(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, transformationOptions.getTargetContentProperty(), parameters);
putParameterIfNotNull(RenditionService.PARAM_DESTINATION_NODE, transformationOptions.getTargetNodeRef(), parameters); putParameterIfNotNull(RenditionService.PARAM_DESTINATION_NODE, transformationOptions.getTargetNodeRef(), parameters);

View File

@@ -430,7 +430,6 @@ public class ThumbnailServiceImpl implements ThumbnailService
// Add the other parameters given in this method signature. // Add the other parameters given in this method signature.
params.put(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, contentProperty); params.put(AbstractRenderingEngine.PARAM_SOURCE_CONTENT_PROPERTY, contentProperty);
params.put(AbstractRenderingEngine.PARAM_MIME_TYPE, mimetype); params.put(AbstractRenderingEngine.PARAM_MIME_TYPE, mimetype);
params.put(RenditionService.PARAM_RENDITION_NODETYPE, ContentModel.TYPE_THUMBNAIL);
// Set the parameters on the rendition definition. // Set the parameters on the rendition definition.
definition.addParameterValues(params); definition.addParameterValues(params);

View File

@@ -261,8 +261,14 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT,
MimetypeMap.MIMETYPE_IMAGE_JPEG, imageTransformationOptions, "small"); MimetypeMap.MIMETYPE_IMAGE_JPEG, imageTransformationOptions, "small");
// Thumbnails should always be of type cm:thumbnail.
assertEquals(ContentModel.TYPE_THUMBNAIL, nodeService.getType(thumbnail1));
// Update the thumbnail // Update the thumbnail
this.thumbnailService.updateThumbnail(thumbnail1, imageTransformationOptions); 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 public void testGetThumbnailByName() throws Exception