RM-4673 - moved try catch in the create method so we can use the group name and fixed an update attribute bug

(cherry picked from commit 9a47da1e6ff050144629ebdd1692bcf9ee35bb56)
This commit is contained in:
Ana Bozianu
2017-02-13 18:20:06 +02:00
parent c61e180dba
commit eee6fe572b
2 changed files with 26 additions and 26 deletions

View File

@@ -243,7 +243,7 @@ public class RecordComponentIdentifierAspect extends BaseBehaviourBean
// Do a blanket removal in case this is a contextual nodes // Do a blanket removal in case this is a contextual nodes
attributeService.removeAttributes(CONTEXT_VALUE, nodeRef); attributeService.removeAttributes(CONTEXT_VALUE, nodeRef);
} }
else else if(!beforeId.equals(afterId))
{ {
// This is a full update // This is a full update
attributeService.updateOrCreateAttribute( attributeService.updateOrCreateAttribute(

View File

@@ -56,6 +56,7 @@ import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.extensions.webscripts.ui.common.StringUtils; import org.springframework.extensions.webscripts.ui.common.StringUtils;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -356,16 +357,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
if (groupResult.getFirst() == null) if (groupResult.getFirst() == null)
{ {
try group = createIPRGroup(groupPrefix, authorities, groupResult.getSecond());
{
group = createIPRGroup(groupPrefix, authorities, groupResult.getSecond());
}
catch(DuplicateChildNodeNameException ex)
{
// the group was concurrently created, try to get it again
groupResult = findIPRGroup(groupPrefix, authorities);
group = groupResult.getFirst();
}
} }
else else
{ {
@@ -530,23 +522,31 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index); String groupShortName = getIPRGroupShortName(groupNamePrefix, children, index);
// create group // create group
String group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM)); String group;
try
// add root parent
authorityService.addAuthority(getRootIRPGroup(), group);
// add children if provided
if (children != null)
{ {
for (String child : children) group = authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, Collections.singleton(RMAuthority.ZONE_APP_RM));
// add root parent
authorityService.addAuthority(getRootIRPGroup(), group);
// add children if provided
if (children != null)
{ {
if (authorityService.authorityExists(child) && for (String child : children)
!PermissionService.ALL_AUTHORITIES.equals(child))
{ {
authorityService.addAuthority(group, child); if (authorityService.authorityExists(child) && !PermissionService.ALL_AUTHORITIES.equals(child))
{
authorityService.addAuthority(group, child);
}
} }
} }
} }
catch(DuplicateChildNodeNameException ex)
{
// the group was concurrently created
group = authorityService.getName(AuthorityType.GROUP, groupShortName);
}
return group; return group;
} }