mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V1.3 to HEAD (3180:3203, 3204:3217)
svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3180 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3203 . svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3204 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3217 . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3407 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -118,7 +118,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
nodeService.setProperty(parentRef, ContentModel.PROP_MEMBERS, members);
|
||||
userToAuthorityCache.remove(childName);
|
||||
}
|
||||
else
|
||||
else if (AuthorityType.getAuthorityType(childName).equals(AuthorityType.GROUP))
|
||||
{
|
||||
NodeRef childRef = getAuthorityOrNull(childName);
|
||||
if (childRef == null)
|
||||
@@ -128,6 +128,10 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
nodeService.addChild(parentRef, childRef, ContentModel.ASSOC_MEMBER, QName.createQName("usr", childName,
|
||||
namespacePrefixResolver));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Authorities of the type "+AuthorityType.getAuthorityType(childName)+" may not be added to other authorities");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -156,6 +156,13 @@ public class AuthorityServiceImpl implements AuthorityService
|
||||
|
||||
public void addAuthority(String parentName, String childName)
|
||||
{
|
||||
if (AuthorityType.getAuthorityType(childName).equals(AuthorityType.USER))
|
||||
{
|
||||
if(!personService.personExists(childName))
|
||||
{
|
||||
throw new AuthorityException("The person "+childName+" does not exist and can not be added to a group");
|
||||
}
|
||||
}
|
||||
authorityDAO.addAuthority(parentName, childName);
|
||||
}
|
||||
|
||||
|
@@ -310,6 +310,8 @@ public class AuthorityServiceTest extends TestCase
|
||||
|
||||
public void testCreateAuthTree()
|
||||
{
|
||||
personService.getPerson("andy");
|
||||
|
||||
String auth1;
|
||||
String auth2;
|
||||
String auth3;
|
||||
@@ -339,12 +341,12 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
pubAuthorityService.addAuthority(auth5, "andy");
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5));
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
|
||||
@@ -362,7 +364,7 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(0, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth5, false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, auth5, false).contains(auth2));
|
||||
@@ -375,6 +377,8 @@ public class AuthorityServiceTest extends TestCase
|
||||
|
||||
public void testCreateAuthNet()
|
||||
{
|
||||
personService.getPerson("andy");
|
||||
|
||||
String auth1;
|
||||
String auth2;
|
||||
String auth3;
|
||||
@@ -399,14 +403,14 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
pubAuthorityService.addAuthority(auth5, "andy");
|
||||
pubAuthorityService.addAuthority(auth1, "andy");
|
||||
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5));
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
|
||||
@@ -425,7 +429,7 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5));
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
|
||||
@@ -440,6 +444,8 @@ public class AuthorityServiceTest extends TestCase
|
||||
|
||||
public void testCreateAuthNet2()
|
||||
{
|
||||
personService.getPerson("andy");
|
||||
|
||||
String auth1;
|
||||
String auth2;
|
||||
String auth3;
|
||||
@@ -464,14 +470,14 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
pubAuthorityService.addAuthority(auth5, "andy");
|
||||
pubAuthorityService.addAuthority(auth1, "andy");
|
||||
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5));
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
|
||||
@@ -491,7 +497,7 @@ public class AuthorityServiceTest extends TestCase
|
||||
assertEquals(5, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(2, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
// The next call looks for people not users :-)
|
||||
assertEquals(2, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(3, pubAuthorityService.getAllAuthorities(AuthorityType.USER).size());
|
||||
assertEquals(4, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth5));
|
||||
assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
|
||||
|
@@ -26,6 +26,8 @@ public class ExtendedPermissionServiceTest extends AbstractPermissionTest
|
||||
{
|
||||
public void testGroupPermission()
|
||||
{
|
||||
personService.getPerson("andy");
|
||||
|
||||
runAs("andy");
|
||||
assertFalse(permissionService.hasPermission(rootNodeRef, getPermission(PermissionService.READ)) == AccessStatus.ALLOWED);
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ),
|
||||
@@ -41,6 +43,8 @@ public class ExtendedPermissionServiceTest extends AbstractPermissionTest
|
||||
|
||||
public void testDeletePermissionByRecipient()
|
||||
{
|
||||
personService.getPerson("andy");
|
||||
|
||||
runAs("andy");
|
||||
assertFalse(permissionService.hasPermission(rootNodeRef, getPermission(PermissionService.READ)) == AccessStatus.ALLOWED);
|
||||
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ),
|
||||
|
Reference in New Issue
Block a user