Package com.atlassian.crowd.directory
Class DbCachingRemoteChangeOperations
java.lang.Object
com.atlassian.crowd.directory.DbCachingRemoteChangeOperations
- All Implemented Interfaces:
DirectoryCacheChangeOperations
public class DbCachingRemoteChangeOperations
extends Object
implements DirectoryCacheChangeOperations
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.crowd.directory.DirectoryCacheChangeOperations
DirectoryCacheChangeOperations.AddRemoveSets<T>, DirectoryCacheChangeOperations.GroupShadowingType, DirectoryCacheChangeOperations.GroupsToAddUpdateReplace -
Constructor Summary
ConstructorsConstructorDescriptionDbCachingRemoteChangeOperations(DirectoryDao directoryDao, RemoteDirectory remoteDirectory, InternalRemoteDirectory internalDirectory, SynchronisationStatusManager synchronisationStatusManager, MultiEventPublisher eventPublisher, UserDao userDao, GroupDao groupDao, GroupActionStrategy groupActionStrategy, CrowdDarkFeatureManager crowdDarkFeatureManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToAdd) voidaddGroups(Set<GroupTemplate> groupsToAdd) voidaddGroupToGroup(String childGroup, String parentGroup) voidaddOrUpdateCachedGroup(Group group) voidaddOrUpdateCachedUser(User user) voidaddUserMembershipsForGroup(Group group, Set<String> usersToAdd) voidaddUsers(Set<UserTemplateWithCredentialAndAttributes> usersToAdd) voidaddUserToGroup(String username, String groupName) voidapplySyncingGroupAttributes(String groupName, Set<String> deletedAttributes, Map<String, Set<String>> storedAttributes) Removes any syncing group attributes listed in deletedAttributes, and store any that are listed in storedAttributes If any non-syncing attributes are included, they will be ignoredvoidapplySyncingUserAttributes(String userName, Set<String> deletedAttributes, Map<String, Set<String>> storedAttributes) Removes any syncing user attributes listed in deletedAttributes, and store any that are listed in storedAttributes If any non-syncing attributes are included, they will be ignoredvoiddeleteCachedGroup(String groupName) voiddeleteCachedGroups(Set<String> groupnames) voiddeleteCachedGroupsByGuids(Set<String> guids) voiddeleteCachedGroupsNotIn(GroupType groupType, List<? extends Group> remoteGroups, Date syncStartDate) voiddeleteCachedGroupsNotInByExternalId(Collection<? extends Group> remoteGroups, Date syncStartDate) voiddeleteCachedUser(String username) voiddeleteCachedUsersByGuid(Set<String> guids) voiddeleteCachedUsersNotIn(Collection<? extends User> remoteUsers, Date synchStartDate) voiddeleteCachedUsersNotInOld(Collection<? extends User> remoteUsers, Date synchStartDate) findGroupMembershipForGroupChanges(Group parentGroup, Collection<String> remoteGroups) findGroupsByExternalIds(Set<String> externalIds) Searches the specified directory for group names of groups with the specified external idsfindGroupsExternalIdsByNames(Set<String> groupNames) Searches the specified directory for externalIds of groups with the specified namesfindGroupsToUpdate(Collection<? extends Group> remoteGroups, Date syncStartDate) findUserMembershipForGroupChanges(Group group, Collection<String> remoteUsers) findUsersByExternalIds(Set<String> externalIds) protected DirectorylonglonglonggetUsersToAddAndUpdate(Collection<? extends User> remoteUsers, Date syncStartDate) Returns the users that need to be added or updated given the list of all remote users.getUsersToAddAndUpdateOld(Collection<? extends User> remoteUsers, Date syncStartDate) protected booleanhasChanged(User remoteUser, User internalUser) isGroupShadowed(Group remoteGroup) Returns true if the given remote Group should not have its memberships synchronised for any reason.protected static Map<String,TimestampedUser> protected static List<org.apache.commons.lang3.tuple.Pair<User,TimestampedUser>> matchUsers(Collection<? extends User> remoteUsers, Collection<? extends TimestampedUser> internalUsers) Returns list ofPair, wherePair.getLeft()is one ofremoteUsersandPair.getRight()is a matchedinternalUsersor null, if not matched.voidremoveGroupFromGroup(String childGroup, String parentGroup) voidremoveGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToRemove) voidremoveGroups(Collection<String> groupsToRemove) voidremoveUserFromGroup(String username, String groupName) voidremoveUserMembershipsForGroup(Group group, Set<String> usersToRemove) voidsyncGroupMembershipsAndMembersForGroup(String groupName, Set<String> parentGroupNames, Set<String> childGroupNames) voidsyncGroupMembershipsForUser(String childUsername, Set<String> parentGroupNames) voidupdateGroups(Collection<GroupTemplate> groupsToUpdate) voidupdateUsers(Collection<UserTemplate> usersToUpdate)
-
Constructor Details
-
DbCachingRemoteChangeOperations
public DbCachingRemoteChangeOperations(DirectoryDao directoryDao, RemoteDirectory remoteDirectory, InternalRemoteDirectory internalDirectory, SynchronisationStatusManager synchronisationStatusManager, MultiEventPublisher eventPublisher, UserDao userDao, GroupDao groupDao, GroupActionStrategy groupActionStrategy, CrowdDarkFeatureManager crowdDarkFeatureManager)
-
-
Method Details
-
addUsers
public void addUsers(Set<UserTemplateWithCredentialAndAttributes> usersToAdd) throws OperationFailedException - Specified by:
addUsersin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
updateUsers
- Specified by:
updateUsersin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedUsersByGuid
- Specified by:
deleteCachedUsersByGuidin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedUsersNotIn
public void deleteCachedUsersNotIn(Collection<? extends User> remoteUsers, Date synchStartDate) throws OperationFailedException - Specified by:
deleteCachedUsersNotInin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedUsersNotInOld
public void deleteCachedUsersNotInOld(Collection<? extends User> remoteUsers, Date synchStartDate) throws OperationFailedException - Throws:
OperationFailedException
-
findGroupsToUpdate
public DirectoryCacheChangeOperations.GroupsToAddUpdateReplace findGroupsToUpdate(Collection<? extends Group> remoteGroups, Date syncStartDate) throws OperationFailedException - Specified by:
findGroupsToUpdatein interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
removeGroups
- Specified by:
removeGroupsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addGroups
- Specified by:
addGroupsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
updateGroups
- Specified by:
updateGroupsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedGroupsNotIn
public void deleteCachedGroupsNotIn(GroupType groupType, List<? extends Group> remoteGroups, Date syncStartDate) throws OperationFailedException - Specified by:
deleteCachedGroupsNotInin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedGroupsNotInByExternalId
public void deleteCachedGroupsNotInByExternalId(Collection<? extends Group> remoteGroups, Date syncStartDate) throws OperationFailedException - Specified by:
deleteCachedGroupsNotInByExternalIdin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedGroups
- Specified by:
deleteCachedGroupsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedGroupsByGuids
- Specified by:
deleteCachedGroupsByGuidsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
hasChanged
-
findUserMembershipForGroupChanges
public DirectoryCacheChangeOperations.AddRemoveSets<String> findUserMembershipForGroupChanges(Group group, Collection<String> remoteUsers) throws OperationFailedException - Specified by:
findUserMembershipForGroupChangesin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
removeUserMembershipsForGroup
public void removeUserMembershipsForGroup(Group group, Set<String> usersToRemove) throws OperationFailedException - Specified by:
removeUserMembershipsForGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addUserMembershipsForGroup
public void addUserMembershipsForGroup(Group group, Set<String> usersToAdd) throws OperationFailedException - Specified by:
addUserMembershipsForGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
findGroupMembershipForGroupChanges
public DirectoryCacheChangeOperations.AddRemoveSets<String> findGroupMembershipForGroupChanges(Group parentGroup, Collection<String> remoteGroups) throws OperationFailedException - Specified by:
findGroupMembershipForGroupChangesin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addGroupMembershipsForGroup
public void addGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToAdd) throws OperationFailedException - Specified by:
addGroupMembershipsForGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
removeGroupMembershipsForGroup
public void removeGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToRemove) throws OperationFailedException - Specified by:
removeGroupMembershipsForGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getLastSyncStartOrEnd
-
getDirectory
- Throws:
DirectoryNotFoundException
-
isGroupShadowed
public DirectoryCacheChangeOperations.GroupShadowingType isGroupShadowed(Group remoteGroup) throws OperationFailedException Returns true if the given remote Group should not have its memberships synchronised for any reason.- Specified by:
isGroupShadowedin interfaceDirectoryCacheChangeOperations- Parameters:
remoteGroup- The Group to test.- Returns:
- true if the given remote Group should not have its memberships synchronised for any reason.
- Throws:
OperationFailedException- If there is an error trying to find the group in the Internal Directory (should not occur).
-
getUsersToAddAndUpdate
public AddUpdateSets<UserTemplateWithCredentialAndAttributes,UserTemplate> getUsersToAddAndUpdate(Collection<? extends User> remoteUsers, Date syncStartDate) throws OperationFailedException Returns the users that need to be added or updated given the list of all remote users. Only the internal users modified beforesyncStartDatewill be updated. This is done to avoid overriding changes made locally to a user after the synchronisation has started.- Specified by:
getUsersToAddAndUpdatein interfaceDirectoryCacheChangeOperations- Parameters:
remoteUsers- List of all remote users.syncStartDate- Date and time of the start of the synchronisation. Used to determine which users need to be synchronised. Can be null in which case all the users are synchronised.- Returns:
- a pair of Sets of users to update and update.
- Throws:
OperationFailedException- if the operation failed for any reason
-
matchUsers
protected static List<org.apache.commons.lang3.tuple.Pair<User,TimestampedUser>> matchUsers(Collection<? extends User> remoteUsers, Collection<? extends TimestampedUser> internalUsers) Returns list ofPair, wherePair.getLeft()is one ofremoteUsersandPair.getRight()is a matchedinternalUsersor null, if not matched. -
getUsersToAddAndUpdateOld
public AddUpdateSets<UserTemplateWithCredentialAndAttributes,UserTemplate> getUsersToAddAndUpdateOld(Collection<? extends User> remoteUsers, Date syncStartDate) throws OperationFailedException - Throws:
OperationFailedException
-
mapUsersByExternalId
protected static Map<String,TimestampedUser> mapUsersByExternalId(Collection<TimestampedUser> users) -
addOrUpdateCachedUser
- Specified by:
addOrUpdateCachedUserin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedUser
- Specified by:
deleteCachedUserin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addOrUpdateCachedGroup
- Specified by:
addOrUpdateCachedGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
deleteCachedGroup
- Specified by:
deleteCachedGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addUserToGroup
- Specified by:
addUserToGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
addGroupToGroup
- Specified by:
addGroupToGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
removeUserFromGroup
- Specified by:
removeUserFromGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws OperationFailedException - Specified by:
removeGroupFromGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
syncGroupMembershipsForUser
public void syncGroupMembershipsForUser(String childUsername, Set<String> parentGroupNames) throws OperationFailedException - Specified by:
syncGroupMembershipsForUserin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
syncGroupMembershipsAndMembersForGroup
public void syncGroupMembershipsAndMembersForGroup(String groupName, Set<String> parentGroupNames, Set<String> childGroupNames) throws OperationFailedException - Specified by:
syncGroupMembershipsAndMembersForGroupin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(String name) throws UserNotFoundException, OperationFailedException - Specified by:
findUserWithAttributesByNamein interfaceDirectoryCacheChangeOperations- Throws:
UserNotFoundExceptionOperationFailedException
-
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(String name) throws GroupNotFoundException, OperationFailedException - Specified by:
findGroupWithAttributesByNamein interfaceDirectoryCacheChangeOperations- Throws:
GroupNotFoundExceptionOperationFailedException
-
findUsersByExternalIds
- Specified by:
findUsersByExternalIdsin interfaceDirectoryCacheChangeOperations
-
findGroupsByExternalIds
public Map<String,String> findGroupsByExternalIds(Set<String> externalIds) throws OperationFailedException Description copied from interface:DirectoryCacheChangeOperationsSearches the specified directory for group names of groups with the specified external ids- Specified by:
findGroupsByExternalIdsin interfaceDirectoryCacheChangeOperations- Parameters:
externalIds- external ids of the groups to find- Returns:
- a map from external ids to group names
- Throws:
OperationFailedException
-
findGroupsExternalIdsByNames
public Map<String,String> findGroupsExternalIdsByNames(Set<String> groupNames) throws OperationFailedException Description copied from interface:DirectoryCacheChangeOperationsSearches the specified directory for externalIds of groups with the specified names- Specified by:
findGroupsExternalIdsByNamesin interfaceDirectoryCacheChangeOperations- Parameters:
groupNames- names of the groups to find- Returns:
- a map from group names to external ids
- Throws:
OperationFailedException
-
applySyncingUserAttributes
public void applySyncingUserAttributes(String userName, Set<String> deletedAttributes, Map<String, Set<String>> storedAttributes) throws UserNotFoundException, OperationFailedExceptionDescription copied from interface:DirectoryCacheChangeOperationsRemoves any syncing user attributes listed in deletedAttributes, and store any that are listed in storedAttributes If any non-syncing attributes are included, they will be ignored- Specified by:
applySyncingUserAttributesin interfaceDirectoryCacheChangeOperations- Parameters:
userName- user to apply attributes todeletedAttributes- attribute keys that need to be deletedstoredAttributes- attributes and values that need to be saved (will overwrite any existing attributes with the same keys)- Throws:
UserNotFoundExceptionOperationFailedException
-
applySyncingGroupAttributes
public void applySyncingGroupAttributes(String groupName, Set<String> deletedAttributes, Map<String, Set<String>> storedAttributes) throws GroupNotFoundException, OperationFailedExceptionDescription copied from interface:DirectoryCacheChangeOperationsRemoves any syncing group attributes listed in deletedAttributes, and store any that are listed in storedAttributes If any non-syncing attributes are included, they will be ignored- Specified by:
applySyncingGroupAttributesin interfaceDirectoryCacheChangeOperations- Parameters:
groupName- group to apply attributes todeletedAttributes- attribute keys that need to be deletedstoredAttributes- attributes and values that need to be saved (will overwrite any existing attributes with the same keys)- Throws:
GroupNotFoundExceptionOperationFailedException
-
getAllUserGuids
- Specified by:
getAllUserGuidsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getAllGroupGuids
- Specified by:
getAllGroupGuidsin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getUserCount
- Specified by:
getUserCountin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getGroupCount
- Specified by:
getGroupCountin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getExternalCachedGroupCount
- Specified by:
getExternalCachedGroupCountin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-
getAllLocalGroupNames
- Specified by:
getAllLocalGroupNamesin interfaceDirectoryCacheChangeOperations- Throws:
OperationFailedException
-