diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java index 5f6bc3b724..de66c5845f 100644 --- a/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java +++ b/source/java/org/alfresco/repo/security/authority/AuthorityServiceImpl.java @@ -294,9 +294,21 @@ public class AuthorityServiceImpl implements AuthorityService, InitializingBean } public void deleteAuthority(String name) + { + deleteAuthority(name, false); + } + + public void deleteAuthority(String name, boolean cascade) { AuthorityType type = AuthorityType.getAuthorityType(name); checkTypeIsMutable(type); + if (cascade) + { + for (String child : getContainedAuthorities(type, name, true)) + { + deleteAuthority(child, true); + } + } authorityDAO.deleteAuthority(name); permissionServiceSPI.deletePermissions(name); } diff --git a/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceImpl.java b/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceImpl.java index b20501acb3..bbe63d501a 100644 --- a/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceImpl.java +++ b/source/java/org/alfresco/repo/security/authority/SimpleAuthorityServiceImpl.java @@ -201,6 +201,11 @@ public class SimpleAuthorityServiceImpl implements AuthorityService } + public void deleteAuthority(String name, boolean cascade) + { + + } + public Set getAllRootAuthorities(AuthorityType type) { return getAllAuthorities(type); diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java index 67b5a42751..0c9c8534ce 100644 --- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java +++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java @@ -926,12 +926,12 @@ public class SiteServiceImpl implements SiteService, SiteModel // Delete the node this.nodeService.deleteNode(siteNodeRef); - // Delete the associated group's + // Delete the associated groups AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { public Object doWork() throws Exception { - authorityService.deleteAuthority(getSiteGroup(shortName, true)); + authorityService.deleteAuthority(getSiteGroup(shortName, true), true); return null; } }, AuthenticationUtil.getSystemUserName()); diff --git a/source/java/org/alfresco/service/cmr/security/AuthorityService.java b/source/java/org/alfresco/service/cmr/security/AuthorityService.java index 9de5fed709..e45993d450 100644 --- a/source/java/org/alfresco/service/cmr/security/AuthorityService.java +++ b/source/java/org/alfresco/service/cmr/security/AuthorityService.java @@ -190,13 +190,25 @@ public interface AuthorityService public void removeAuthority(String parentName, String childName); /** - * Delete an authority and all its relationships. + * Delete an authority and all its relationships. Note child authorities are not deleted. * * @param name */ @Auditable(parameters = {"name"}) public void deleteAuthority(String name); + /** + * Delete an authority and all its relationships, optionally recursively deleting child authorities of the same + * type. + * + * @param name + * the authority long name + * @param cascade + * should the delete be cascaded to child authorities of the same type? + */ + @Auditable(parameters = {"name", "cascade"}) + public void deleteAuthority(String name, boolean cascade); + /** * Get all the authorities that are contained by the given authority. *