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
This commit is contained in:
Roy Wetherall
2011-11-04 14:44:03 +00:00
parent 39139ce976
commit f54aacb177

View File

@@ -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<NodeRef>()
{
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<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return createThumbnailNode( node,
contentProperty,
mimetype,
transformationOptions,
thumbnailName,
assocDetails);
}
}, AuthenticationUtil.getSystemUserName());
}
private QName getThumbnailQName(String localThumbnailName)