Interface MembershipDao

All Known Subinterfaces:
InternalMembershipDao
All Known Implementing Classes:
CachingInternalMembershipDao, CachingMembershipDao, MembershipDAOHibernate

public interface MembershipDao
  • Method Details

    • isUserDirectMember

      boolean isUserDirectMember(long directoryId, String userName, String groupName)
      Determines whether the user is a direct member of the group.
      Parameters:
      directoryId - the directory to perform the operation
      userName - user
      groupName - group
      Returns:
      true if the user is a direct member of the group
    • isGroupDirectMember

      boolean isGroupDirectMember(long directoryId, String childGroup, String parentGroup)
      Determines whether the group is a direct member of the (supposedly) parent group.
      Parameters:
      directoryId - the directory to perform the operation
      childGroup - child group
      parentGroup - parent group
      Returns:
      true if the group is a direct member of the (supposedly) parent group
    • addUserToGroup

      void addUserToGroup(long directoryId, String userName, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipAlreadyExistsException
      Adds user as a member of group.
      Parameters:
      directoryId - the directory to perform the operation
      userName - user
      groupName - group
      Throws:
      UserNotFoundException - if the user does not exist
      GroupNotFoundException - if the group does not exist
      MembershipAlreadyExistsException - if the user is already a direct member of the group
    • addUserToGroups

      BatchResult<String> addUserToGroups(long directoryId, String username, Set<String> groupNames) throws UserNotFoundException
      Bulk adds the given user to all the given groups. Groups that user is already a direct member of are reported as failures. Group names that cannot be found in the database are also reported as failures. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.
      Parameters:
      directoryId - the id of the directory to which user and groups belong
      username - username of the user to whom we add groups
      groupNames - names of the group to add to a user. The groups need to exist in the directory
      Returns:
      result of the bulk operation containing successful and failed entities
      Throws:
      UserNotFoundException - when user with a given username does not exist in the directory with directoryId id
    • addAllUsersToGroup

      BatchResult<String> addAllUsersToGroup(long directoryId, Collection<String> userNames, String groupName) throws GroupNotFoundException
      Bulk adds all the given users into the given group. Users that are already direct members of the group are reported as failures. Usernames that cannot be found in the database are also reported as failures. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.
      Parameters:
      directoryId - the directory to perform the operation
      userNames - the collection of users
      groupName - name of the group
      Returns:
      result containing both successful (membership successfully added) and failed users (unknown username, or already existing membership)
      Throws:
      GroupNotFoundException - if the group does not exist
    • addGroupToGroup

      void addGroupToGroup(long directoryId, String childGroup, String parentGroup) throws GroupNotFoundException, MembershipAlreadyExistsException
      Adds group as a child of the (supposedly) parent group.
      Parameters:
      directoryId - the directory to perform the operation
      childGroup - the (supposedly) child group
      parentGroup - parent group
      Throws:
      GroupNotFoundException - if either child or parent group is not found
      MembershipAlreadyExistsException - if the child group is already a child of the parent group
    • addAllGroupsToGroup

      BatchResult<String> addAllGroupsToGroup(long directoryId, Collection<String> childGroupNames, String groupName) throws GroupNotFoundException
      Bulk adds all the given child groups into the given group. Child groups that are already direct members of the group are reported as failures. childGroupNames that cannot be found in the database are also reported as failures. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.
      Parameters:
      directoryId - the directory to perform the operation
      childGroupNames - the collection of child groups to add
      groupName - name of the group
      Returns:
      result containing both successful (membership successfully added) and failed groups (unknown childGroupName, or already existing membership)
      Throws:
      GroupNotFoundException - if the group does not exist
    • removeUserFromGroup

      void removeUserFromGroup(long directoryId, String userName, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipNotFoundException
      Removes user as a member of the given group.
      Parameters:
      directoryId - the directory to perform the operation
      userName - user
      groupName - group
      Throws:
      UserNotFoundException - if the user does not exist
      GroupNotFoundException - if the group does not exist
      MembershipNotFoundException - if the user is not a member of the said group
    • removeUsersFromGroup

      BatchResult<String> removeUsersFromGroup(long directoryId, Collection<String> usernames, String groupName) throws GroupNotFoundException
      Bulk remove all the given users into the given group. Users that are not direct members of the group are reported as failures. Usernames that cannot be found in the database are also reported as failures. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.
      Parameters:
      directoryId - the directory to perform the operation
      usernames - the collection of users
      groupName - name of the group
      Returns:
      result containing both successful (membership successfully removed) and failed users (unknown username, or no existing membership)
      Throws:
      GroupNotFoundException - if the group does not exist
    • removeGroupFromGroup

      void removeGroupFromGroup(long directoryId, String childGroup, String parentGroup) throws GroupNotFoundException, MembershipNotFoundException
      Removes group from the parent group.
      Parameters:
      directoryId - the directory to perform the operation
      childGroup - child group
      parentGroup - parent group
      Throws:
      GroupNotFoundException - if either child or parent group does not exist
      MembershipNotFoundException - if the membership relationship between the child and parent group does not exist
    • removeGroupsFromGroup

      BatchResult<String> removeGroupsFromGroup(long directoryId, Collection<String> childGroupNames, String groupName) throws GroupNotFoundException
      Bulk remove all the given child groups from the given group. Child groups that are not direct members of the group are reported as failures. childGroupNames that cannot be found in the database are also reported as failures. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.
      Parameters:
      directoryId - the directory to perform the operation
      childGroupNames - the collection of child groups
      groupName - name of the parent group
      Returns:
      result containing both successful (membership successfully removed) and failed groups (unknown childGroupName, or no existing membership)
      Throws:
      GroupNotFoundException - if the parent group does not exist
    • search

      <T> List<T> search(long directoryId, MembershipQuery<T> query)
      Search for memberships by the given criteria.
      Parameters:
      directoryId - the directory to perform the operation
      query - criteria
      Returns:
      List (can be empty but never null) of memberships which match the given criteria. Results are ordered by entity name, case-insensitive.
    • searchGroupedByName

      <T> Map<String,List<T>> searchGroupedByName(long directoryId, MembershipQuery<T> query)
      Search for memberships by the given criteria. Groups results by MembershipQuery.getEntityNamesToMatch().
      Parameters:
      directoryId - the directory to perform the operation
      query - criteria
      Returns:
      List (can be empty but never null) of memberships which match the given criteria. Results are ordered by entity name, case-insensitive.
    • countDirectMembersOfGroup

      BoundedCount countDirectMembersOfGroup(long directoryId, String groupName, int potentialMaxCount)

      Count the direct members of a group with a recommended upper bound on the count.

      The upper bound is there so that, in directories that do not support efficient counting of memberships, less work may be performed.

      Important: Please note that any directory wishing to implement this method should make it as efficient as possible. Such that an administrator could land on a page that showed ~20 groups, run this method once per group, and it would still return results as efficiently as possible.

      Parameters:
      directoryId - the directory to perform the operation
      groupName - the name of the group to search for
      potentialMaxCount - a suggested minimum number of elements for the implementation to count. The implementation will only use this number if it can get efficiency benefits; otherwise this number may be ignored.
      Returns:
      A bounded count of the number of memberships in the given group for the provided directory. If the group does not exist then BoundedCount.exactly(long) 0 will be returned.