Class OptimizedCanonicalityChecker
java.lang.Object
com.atlassian.crowd.manager.application.canonicality.OptimizedCanonicalityChecker
- All Implemented Interfaces:
CanonicalityChecker
Optimized implementation of
CanonicalityChecker.
This implementation is efficient for multiple calls, as it pre-fetches data.
Limits number of queries to one per directory and entity type combination.
Keeps only shadowed names to decrease memory usage.
Does not implement CanonicalityChecker.groupByCanonicalId(Set, EntityDescriptor) - can't be used for
parent queries.-
Constructor Summary
ConstructorsConstructorDescriptionOptimizedCanonicalityChecker(DirectoryManager directoryManager, List<Directory> directories) OptimizedCanonicalityChecker(DirectoryManager directoryManager, List<Directory> directories, Map<EntityDescriptor, LongFunction<Collection<String>>> providers) -
Method Summary
Modifier and TypeMethodDescriptiongroupByCanonicalId(Set<String> names, EntityDescriptor entity) Returns names grouped by their canonical directory id.voidremoveNonCanonicalEntities(com.google.common.collect.Multimap<Long, String> allNames, EntityDescriptor entity) Given a username is duplicated in severaluser directoriesunder the sameapplication.
-
Constructor Details
-
OptimizedCanonicalityChecker
-
OptimizedCanonicalityChecker
public OptimizedCanonicalityChecker(DirectoryManager directoryManager, List<Directory> directories, Map<EntityDescriptor, LongFunction<Collection<String>>> providers)
-
-
Method Details
-
removeNonCanonicalEntities
public void removeNonCanonicalEntities(com.google.common.collect.Multimap<Long, String> allNames, EntityDescriptor entity) Description copied from interface:CanonicalityCheckerGiven a username is duplicated in several
user directoriesunder 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:
removeNonCanonicalEntitiesin interfaceCanonicalityChecker- Parameters:
allNames- a directoryId to list of entities map containing the entities to check for canonicality.entity- 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 entity) Description copied from interface:CanonicalityCheckerReturns names grouped by their canonical directory id. Case-sensitivity of the provided names is preserved. Names not found won't be returned.- Specified by:
groupByCanonicalIdin interfaceCanonicalityChecker- Parameters:
names- names to be groupedentity- entity to which the names are referring to- Returns:
- names grouped by their canonical directory id
-
getDirectories
- Specified by:
getDirectoriesin interfaceCanonicalityChecker- Returns:
- ordered list of directories for which the canonicality is computed
-