mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Duplicate blog names (uses System.currentTimeMillis) are handled as a concurrency violation
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32440 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -48,6 +48,7 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
@@ -65,6 +66,7 @@ import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
* @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
|
||||
@@ -234,8 +236,19 @@ public class BlogServiceImpl implements BlogService
|
||||
nodeProps.put(ContentModel.PROP_NAME, nodeName);
|
||||
nodeProps.put(ContentModel.PROP_TITLE, blogTitle);
|
||||
QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName);
|
||||
ChildAssociationRef postNode = nodeService.createNode(blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
|
||||
ContentModel.TYPE_CONTENT, nodeProps);
|
||||
ChildAssociationRef postNode = null;
|
||||
try
|
||||
{
|
||||
postNode = nodeService.createNode(
|
||||
blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
|
||||
ContentModel.TYPE_CONTENT, nodeProps);
|
||||
}
|
||||
catch (DuplicateChildNodeNameException e)
|
||||
{
|
||||
// This will be rare, but it's not impossible.
|
||||
// We have to retry the operation.
|
||||
throw new ConcurrencyFailureException("Blog post name already used: " + nodeName);
|
||||
}
|
||||
|
||||
ContentWriter writer = contentService.getWriter(postNode.getChildRef(), ContentModel.PROP_CONTENT, true);
|
||||
|
||||
|
Reference in New Issue
Block a user