From f54aacb17718ef5617a524178d22bbfbb04b31c1 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 4 Nov 2011 14:44:03 +0000 Subject: [PATCH] ALF-9605: Failure to create thumbnails during simultaneous upload of similarly named files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/thumbnail/ThumbnailServiceImpl.java | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java index 823c1a5e69..86151dc432 100644 --- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java +++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java @@ -239,38 +239,34 @@ public class ThumbnailServiceImpl implements ThumbnailService, logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype); } - checkThumbnailNameIsUnique(node, thumbnailName, contentProperty, mimetype); - return AuthenticationUtil.runAs( - new AuthenticationUtil.RunAsWork() - { - public NodeRef doWork() throws Exception - { - return createThumbnailNode(node, contentProperty, - mimetype, transformationOptions, thumbnailName, assocDetails); - } - }, AuthenticationUtil.getSystemUserName()); - } - - /** - * Throws a ThumbnailException if a thumbnail of this name already exists. - * @param node - * @param thumbnailName - * @param contentProperty - * @param mimetype - */ - private void checkThumbnailNameIsUnique(final NodeRef node, final String thumbnailName, - final QName contentProperty, final String mimetype) - { - if (thumbnailName != null && getThumbnailByName(node, contentProperty, thumbnailName) != null) + + if (thumbnailName != null) { - if (logger.isDebugEnabled() == true) + NodeRef existingThumbnail = getThumbnailByName(node, contentProperty, thumbnailName); + if (existingThumbnail != null) { - logger.debug("Creating thumbnail: There is already a thumbnail with the name '" + thumbnailName + "' (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype); + if (logger.isDebugEnabled() == true) + { + logger.debug("Creating thumbnail: There is already a thumbnail with the name '" + thumbnailName + "' (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype); + } + + // Return the thumbnail that has already been created + return existingThumbnail; } - - // We can't continue because there is already a thumbnail with the given name for that content property - throw new ThumbnailException(ERR_DUPLICATE_NAME); } + + return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() + { + public NodeRef doWork() throws Exception + { + return createThumbnailNode( node, + contentProperty, + mimetype, + transformationOptions, + thumbnailName, + assocDetails); + } + }, AuthenticationUtil.getSystemUserName()); } private QName getThumbnailQName(String localThumbnailName)