mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
19109: Merged V3.2.0 to V3.2 19098: ALF-1960: Fixed issues when syncing with deeply nested LDAP groups git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19116 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1152,10 +1153,23 @@ public class ChainingUserRegistrySynchronizer extends AbstractLifecycleBean impl
|
||||
// Filter out associations to unknown parent authorities
|
||||
associations.retainAll(allAuthorities);
|
||||
int insertIndex = authorityPath.size();
|
||||
for (String parentAuthority : associations)
|
||||
Iterator<String> i = associations.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
String parentAuthority = i.next();
|
||||
|
||||
// Prevent cyclic paths
|
||||
if (!authorityPath.contains(parentAuthority))
|
||||
if (authorityPath.contains(parentAuthority))
|
||||
{
|
||||
if (ChainingUserRegistrySynchronizer.logger.isWarnEnabled())
|
||||
{
|
||||
ChainingUserRegistrySynchronizer.logger.warn("Detected cyclic dependencies in group '"
|
||||
+ ChainingUserRegistrySynchronizer.this.authorityService.getShortName(parentAuthority)
|
||||
+ "'");
|
||||
}
|
||||
i.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
authorityPath.add(parentAuthority);
|
||||
visitGroupAssociations(authorityPath, allAuthorities, associationsOld, associationsNew);
|
||||
|
@@ -29,6 +29,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -363,7 +364,7 @@ public class ChainingUserRegistrySynchronizerTest extends TestCase
|
||||
public void testVolume() throws Exception
|
||||
{
|
||||
List<NodeDescription> persons = new ArrayList<NodeDescription>(new RandomPersonCollection(100));
|
||||
List<NodeDescription> groups = new ArrayList<NodeDescription>(new RandomGroupCollection(100, persons));
|
||||
List<NodeDescription> groups = new ArrayList<NodeDescription>(new RandomGroupCollection(50, persons));
|
||||
this.applicationContextManager.setUserRegistries(new MockUserRegistry("Z0", persons, groups));
|
||||
this.synchronizer.synchronize(true, true, true);
|
||||
tearDownTestUsersAndGroups();
|
||||
@@ -777,6 +778,8 @@ public class ChainingUserRegistrySynchronizerTest extends TestCase
|
||||
*/
|
||||
public class RandomGroupCollection extends AbstractCollection<NodeDescription>
|
||||
{
|
||||
/** Use a fixed seed to give this class deterministic behaviour */
|
||||
private Random generator = new Random(1628876500L);
|
||||
|
||||
/** The collection size. */
|
||||
private final int size;
|
||||
@@ -839,12 +842,16 @@ public class ChainingUserRegistrySynchronizerTest extends TestCase
|
||||
String[] authorityNames = new String[17];
|
||||
for (int i = 0; i < authorityNames.length; i++)
|
||||
{
|
||||
// Choose an authority at random from the list of known authorities
|
||||
int index = RandomGroupCollection.this.generator.nextInt(RandomGroupCollection.this.authorities
|
||||
.size());
|
||||
authorityNames[i] = ChainingUserRegistrySynchronizerTest.this.authorityService
|
||||
.getShortName((String) RandomGroupCollection.this.authorities
|
||||
.get((int) (Math.random() * (double) (RandomGroupCollection.this.authorities
|
||||
.size() - 1))));
|
||||
.getShortName((String) RandomGroupCollection.this.authorities.get(index));
|
||||
}
|
||||
return newGroup("G" + GUID.generate(), authorityNames);
|
||||
NodeDescription group = newGroup("G" + GUID.generate(), authorityNames);
|
||||
// Make this group a candidate for adding to other groups
|
||||
RandomGroupCollection.this.authorities.add((String) group.getProperties().get(ContentModel.PROP_AUTHORITY_NAME));
|
||||
return group;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
|
Reference in New Issue
Block a user