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
ConstructorDescriptionDbCachingRemoteChangeOperations
(DirectoryDao directoryDao, RemoteDirectory remoteDirectory, InternalRemoteDirectory internalDirectory, SynchronisationStatusManager synchronisationStatusManager, MultiEventPublisher eventPublisher, UserDao userDao, GroupDao groupDao, GroupActionStrategy groupActionStrategy, CrowdDarkFeatureManager crowdDarkFeatureManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGroupMembershipsForGroup
(Group parentGroup, Collection<String> groupsToAdd) void
addGroups
(Set<GroupTemplate> groupsToAdd) void
addGroupToGroup
(String childGroup, String parentGroup) void
addOrUpdateCachedGroup
(Group group) void
addOrUpdateCachedUser
(User user) void
addUserMembershipsForGroup
(Group group, Set<String> usersToAdd) void
addUsers
(Set<UserTemplateWithCredentialAndAttributes> usersToAdd) void
addUserToGroup
(String username, String groupName) void
applySyncingGroupAttributes
(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 ignoredvoid
applySyncingUserAttributes
(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 ignoredvoid
deleteCachedGroup
(String groupName) void
deleteCachedGroups
(Set<String> groupnames) void
deleteCachedGroupsByGuids
(Set<String> guids) void
deleteCachedGroupsNotIn
(GroupType groupType, List<? extends Group> remoteGroups, Date syncStartDate) void
deleteCachedGroupsNotInByExternalId
(Collection<? extends Group> remoteGroups, Date syncStartDate) void
deleteCachedUser
(String username) void
deleteCachedUsersByGuid
(Set<String> guids) void
deleteCachedUsersNotIn
(Collection<? extends User> remoteUsers, Date synchStartDate) void
deleteCachedUsersNotInOld
(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 Directory
long
long
long
getUsersToAddAndUpdate
(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 boolean
hasChanged
(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 ofremoteUsers
andPair.getRight()
is a matchedinternalUsers
or null, if not matched.void
removeGroupFromGroup
(String childGroup, String parentGroup) void
removeGroupMembershipsForGroup
(Group parentGroup, Collection<String> groupsToRemove) void
removeGroups
(Collection<String> groupsToRemove) void
removeUserFromGroup
(String username, String groupName) void
removeUserMembershipsForGroup
(Group group, Set<String> usersToRemove) void
syncGroupMembershipsAndMembersForGroup
(String groupName, Set<String> parentGroupNames, Set<String> childGroupNames) void
syncGroupMembershipsForUser
(String childUsername, Set<String> parentGroupNames) void
updateGroups
(Collection<GroupTemplate> groupsToUpdate) void
updateUsers
(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:
addUsers
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
updateUsers
- Specified by:
updateUsers
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedUsersByGuid
- Specified by:
deleteCachedUsersByGuid
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedUsersNotIn
public void deleteCachedUsersNotIn(Collection<? extends User> remoteUsers, Date synchStartDate) throws OperationFailedException - Specified by:
deleteCachedUsersNotIn
in 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:
findGroupsToUpdate
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
removeGroups
- Specified by:
removeGroups
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addGroups
- Specified by:
addGroups
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
updateGroups
- Specified by:
updateGroups
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedGroupsNotIn
public void deleteCachedGroupsNotIn(GroupType groupType, List<? extends Group> remoteGroups, Date syncStartDate) throws OperationFailedException - Specified by:
deleteCachedGroupsNotIn
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedGroupsNotInByExternalId
public void deleteCachedGroupsNotInByExternalId(Collection<? extends Group> remoteGroups, Date syncStartDate) throws OperationFailedException - Specified by:
deleteCachedGroupsNotInByExternalId
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedGroups
- Specified by:
deleteCachedGroups
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedGroupsByGuids
- Specified by:
deleteCachedGroupsByGuids
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
hasChanged
-
findUserMembershipForGroupChanges
public DirectoryCacheChangeOperations.AddRemoveSets<String> findUserMembershipForGroupChanges(Group group, Collection<String> remoteUsers) throws OperationFailedException - Specified by:
findUserMembershipForGroupChanges
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
removeUserMembershipsForGroup
public void removeUserMembershipsForGroup(Group group, Set<String> usersToRemove) throws OperationFailedException - Specified by:
removeUserMembershipsForGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addUserMembershipsForGroup
public void addUserMembershipsForGroup(Group group, Set<String> usersToAdd) throws OperationFailedException - Specified by:
addUserMembershipsForGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
findGroupMembershipForGroupChanges
public DirectoryCacheChangeOperations.AddRemoveSets<String> findGroupMembershipForGroupChanges(Group parentGroup, Collection<String> remoteGroups) throws OperationFailedException - Specified by:
findGroupMembershipForGroupChanges
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addGroupMembershipsForGroup
public void addGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToAdd) throws OperationFailedException - Specified by:
addGroupMembershipsForGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
removeGroupMembershipsForGroup
public void removeGroupMembershipsForGroup(Group parentGroup, Collection<String> groupsToRemove) throws OperationFailedException - Specified by:
removeGroupMembershipsForGroup
in 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:
isGroupShadowed
in 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 beforesyncStartDate
will be updated. This is done to avoid overriding changes made locally to a user after the synchronisation has started.- Specified by:
getUsersToAddAndUpdate
in 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 ofremoteUsers
andPair.getRight()
is a matchedinternalUsers
or 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:
addOrUpdateCachedUser
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedUser
- Specified by:
deleteCachedUser
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addOrUpdateCachedGroup
- Specified by:
addOrUpdateCachedGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
deleteCachedGroup
- Specified by:
deleteCachedGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addUserToGroup
- Specified by:
addUserToGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
addGroupToGroup
- Specified by:
addGroupToGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
removeUserFromGroup
- Specified by:
removeUserFromGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws OperationFailedException - Specified by:
removeGroupFromGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
syncGroupMembershipsForUser
public void syncGroupMembershipsForUser(String childUsername, Set<String> parentGroupNames) throws OperationFailedException - Specified by:
syncGroupMembershipsForUser
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
syncGroupMembershipsAndMembersForGroup
public void syncGroupMembershipsAndMembersForGroup(String groupName, Set<String> parentGroupNames, Set<String> childGroupNames) throws OperationFailedException - Specified by:
syncGroupMembershipsAndMembersForGroup
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(String name) throws UserNotFoundException, OperationFailedException - Specified by:
findUserWithAttributesByName
in interfaceDirectoryCacheChangeOperations
- Throws:
UserNotFoundException
OperationFailedException
-
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(String name) throws GroupNotFoundException, OperationFailedException - Specified by:
findGroupWithAttributesByName
in interfaceDirectoryCacheChangeOperations
- Throws:
GroupNotFoundException
OperationFailedException
-
findUsersByExternalIds
- Specified by:
findUsersByExternalIds
in interfaceDirectoryCacheChangeOperations
-
findGroupsByExternalIds
public Map<String,String> findGroupsByExternalIds(Set<String> externalIds) throws OperationFailedException Description copied from interface:DirectoryCacheChangeOperations
Searches the specified directory for group names of groups with the specified external ids- Specified by:
findGroupsByExternalIds
in 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:DirectoryCacheChangeOperations
Searches the specified directory for externalIds of groups with the specified names- Specified by:
findGroupsExternalIdsByNames
in 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:DirectoryCacheChangeOperations
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 ignored- Specified by:
applySyncingUserAttributes
in 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:
UserNotFoundException
OperationFailedException
-
applySyncingGroupAttributes
public void applySyncingGroupAttributes(String groupName, Set<String> deletedAttributes, Map<String, Set<String>> storedAttributes) throws GroupNotFoundException, OperationFailedExceptionDescription copied from interface:DirectoryCacheChangeOperations
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 ignored- Specified by:
applySyncingGroupAttributes
in 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:
GroupNotFoundException
OperationFailedException
-
getAllUserGuids
- Specified by:
getAllUserGuids
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
getAllGroupGuids
- Specified by:
getAllGroupGuids
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
getUserCount
- Specified by:
getUserCount
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
getGroupCount
- Specified by:
getGroupCount
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
getExternalCachedGroupCount
- Specified by:
getExternalCachedGroupCount
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-
getAllLocalGroupNames
- Specified by:
getAllLocalGroupNames
in interfaceDirectoryCacheChangeOperations
- Throws:
OperationFailedException
-