Class SimpleCanonicalityChecker
java.lang.Object
com.atlassian.crowd.manager.application.canonicality.SimpleCanonicalityChecker
- All Implemented Interfaces:
CanonicalityChecker
Simple implementation of
CanonicalityChecker
.
This implementation is not efficient for multiple calls, as it fetches required data incrementally.-
Field Summary
-
Constructor Summary
ConstructorDescriptionSimpleCanonicalityChecker
(DirectoryManager directoryManager, List<Directory> directories) -
Method Summary
Modifier and TypeMethodDescriptiongroupByCanonicalId
(Set<String> names, EntityDescriptor entityDescriptor) Returns names grouped by their canonical directory id.void
removeNonCanonicalEntities
(com.google.common.collect.Multimap<Long, String> allNames, EntityDescriptor entityDescriptor) Given a username is duplicated in severaluser directories
under the sameapplication
.
-
Field Details
-
BATCH_SIZE
protected static final int BATCH_SIZE- See Also:
-
-
Constructor Details
-
SimpleCanonicalityChecker
-
-
Method Details
-
removeNonCanonicalEntities
public void removeNonCanonicalEntities(com.google.common.collect.Multimap<Long, String> allNames, EntityDescriptor entityDescriptor) Description copied from interface:CanonicalityChecker
Given a username is duplicated in several
user directories
under the sameapplication
.The user in the first directory, according to directory ordering is considered to be the canonical user for the given username, and the other users are shadowed and thus not to be returned from searches.
This method removes all entities which were found for a given directory, but were not canonical in it (they existed in a preceding directory, not necessarily in the allEntities map). The allEntities map will be mutated in the process. For example: Given the following directories and entities:- Directory 1 - Users A, B, C
- Directory 2 - Users C, D, E
- Directory 1 - Users A, B, C
- Directory 2 - User E
- Specified by:
removeNonCanonicalEntities
in interfaceCanonicalityChecker
- Parameters:
allNames
- a directoryId to list of entities map containing the entities to check for canonicality.entityDescriptor
- the EntityDescriptor used to look up the entities that will be determined as canonical
-
groupByCanonicalId
public com.google.common.collect.SetMultimap<Long,String> groupByCanonicalId(Set<String> names, EntityDescriptor entityDescriptor) Description copied from interface:CanonicalityChecker
Returns names grouped by their canonical directory id. Case-sensitivity of the provided names is preserved. Names not found won't be returned.- Specified by:
groupByCanonicalId
in interfaceCanonicalityChecker
- Parameters:
names
- names to be groupedentityDescriptor
- entity to which the names are referring to- Returns:
- names grouped by their canonical directory id
-
getDirectories
- Specified by:
getDirectories
in interfaceCanonicalityChecker
- Returns:
- ordered list of directories for which the canonicality is computed
-