diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java index 2903615450..8f423c16b8 100644 --- a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java +++ b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java @@ -377,6 +377,9 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor public void createAuthority(String name, String authorityDisplayName, Set authorityZones) { HashMap props = new HashMap(); + //MNT-9794 fix. ContentModel.PROP_NAME is added for preventing the generation of new uid for every new authority + // nodes with the duplicated names in 'child_node_name' field into 'alf_child_assoc' table + props.put(ContentModel.PROP_NAME, name); props.put(ContentModel.PROP_AUTHORITY_NAME, name); props.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, authorityDisplayName); NodeRef childRef; diff --git a/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java b/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java index b23ee87f58..2f1de63dd9 100644 --- a/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java +++ b/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java @@ -44,8 +44,10 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.MutableAuthenticationDao; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; +import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ChildAssociationRef; +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.repository.datatype.DefaultTypeConverter; @@ -59,6 +61,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; +import org.junit.Test; import org.springframework.context.ApplicationContext; public class AuthorityServiceTest extends TestCase @@ -110,7 +113,7 @@ public class AuthorityServiceTest extends TestCase String defaultAdminUser = AuthenticationUtil.getAdminUserName(); AuthenticationUtil.setFullyAuthenticatedUser(defaultAdminUser); - + // note: currently depends on any existing (and/or bootstrap) group data - eg. default site "swsdp" (Sample Web Site Design Project) SiteService siteService = (SiteService) ctx.getBean("SiteService"); SITE_CNT = siteService.listSites(defaultAdminUser).size(); @@ -593,6 +596,23 @@ public class AuthorityServiceTest extends TestCase assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.ROLE).size()); } + public void createAuthority(final AuthorityType dublicatedAuthorityType, final String dublicatedAuthorityShortName) + { + final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); + TransactionService transactionService = serviceRegistry.getTransactionService(); + + RetryingTransactionCallback exampleWork = new RetryingTransactionCallback() { + public Object execute() throws Exception + { + pubAuthorityService.createAuthority(dublicatedAuthorityType, + dublicatedAuthorityShortName); + return null; + } + }; + transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork); + } + } + private void checkAuthorityCollectionSize(int expected, List actual, AuthorityType type) { if (actual.size() != expected)