Interface GroupService

All Superinterfaces:
DSpaceObjectLegacySupportService<Group>, DSpaceObjectService<Group>
All Known Implementing Classes:
GroupServiceImpl

public interface GroupService extends DSpaceObjectService<Group>, DSpaceObjectLegacySupportService<Group>
Service interface class for the Group object. The implementation of this class is responsible for all business logic calls for the Group object and is autowired by Spring.
Author:
kevinvandevelde at atmire.com
  • Field Details

  • Method Details

    • create

      Group create(Context context) throws SQLException, AuthorizeException
      Create a new group
      Parameters:
      context - DSpace context object
      Returns:
      group
      Throws:
      SQLException - if database error
      AuthorizeException - if authorization error
    • setName

      void setName(Group group, String name) throws SQLException
      set name of group
      Parameters:
      group - DSpace group
      name - new group name
      Throws:
      SQLException - if database error
    • addMember

      void addMember(Context context, Group group, EPerson e)
      add an eperson member
      Parameters:
      context - DSpace context object
      group - DSpace group
      e - eperson
    • addMember

      void addMember(Context context, Group groupParent, Group groupChild) throws SQLException
      add group to this group. Be sure to call the #update(Context, Group) method once that all the membership are set to trigger the rebuild of the group2group cache table
      Parameters:
      context - DSpace context object
      groupParent - parent group
      groupChild - child group
      Throws:
      SQLException - if database error
    • removeMember

      void removeMember(Context context, Group group, EPerson ePerson) throws SQLException
      remove an eperson from a group
      Parameters:
      context - DSpace context object
      group - DSpace group
      ePerson - eperson
      Throws:
      SQLException
    • removeMember

      void removeMember(Context context, Group groupParent, Group childGroup) throws SQLException
      remove group from this group. Be sure to call the #update(Context, Group) method once that all the membership are set to trigger the rebuild of the group2group cache table
      Parameters:
      context - DSpace context object
      groupParent - parent group
      childGroup - child group
      Throws:
      SQLException - if database error
    • isDirectMember

      boolean isDirectMember(Group group, EPerson ePerson)
      check to see if an eperson is a direct member. If the eperson is a member via a subgroup will be returned false
      Parameters:
      group - DSpace group
      ePerson - eperson to check membership
      Returns:
      true or false
    • isMember

      boolean isMember(Group owningGroup, Group childGroup)
      Check to see if childGroup is a direct group member of owningGroup. If childGroup is a subgroup via another group will be returned false
      Parameters:
      owningGroup - parent group
      childGroup - child group
      Returns:
      true or false
    • isParentOf

      boolean isParentOf(Context context, Group parentGroup, Group childGroup) throws SQLException
      Check to see if parentGroup is a direct or in-direct parent of a childGroup.
      Parameters:
      context - current DSpace session.
      parentGroup - parent group
      childGroup - child group
      Returns:
      true or false
      Throws:
      SQLException
    • isMember

      boolean isMember(Context context, Group group) throws SQLException
      fast check to see if an eperson is a member called with eperson id. Does database lookup without instantiating all of the eperson objects and is thus a static method
      Parameters:
      context - context
      group - group to check
      Returns:
      true or false
      Throws:
      SQLException - if database error
    • isMember

      boolean isMember(Context context, String groupName) throws SQLException
      fast check to see if an eperson is a member called with eperson id. Does database lookup without instantiating all of the eperson objects and is thus a static method. This method uses context.getCurrentUser() as eperson whose membership should be checked.
      Parameters:
      context - context
      groupName - the name of the group to check
      Returns:
      true or false
      Throws:
      SQLException - if database error
    • isMember

      boolean isMember(Context context, EPerson epersonToCheck, String groupName) throws SQLException
      fast check to see if an eperson is a member called with eperson id. Does database lookup without instantiating all of the eperson objects and is thus a static method. The eperson whose membership should be checked must be defined as method attribute.
      Parameters:
      context - context
      epersonToCheck - is this EPerson a member of the group?
      groupName - the name of the group to check
      Returns:
      true or false
      Throws:
      SQLException - if database error
    • isMember

      boolean isMember(Context context, EPerson eperson, Group group) throws SQLException
      fast check to see if an eperson is a member called with eperson id. Does database lookup without instantiating all of the eperson objects and is thus a static method.
      Parameters:
      context - DSpace context object.
      eperson - EPerson whose membership should be checked.
      group - The group to check against.
      Returns:
      true or false
      Throws:
      SQLException - if database error
    • allMemberGroups

      List<Group> allMemberGroups(Context context, EPerson ePerson) throws SQLException
      Get all of the groups that an eperson is a member of.
      Parameters:
      context - DSpace context
      ePerson - ePerson object
      Returns:
      list of Group objects
      Throws:
      SQLException - if database error
    • allMemberGroupsSet

      Set<Group> allMemberGroupsSet(Context context, EPerson ePerson) throws SQLException
      Throws:
      SQLException
    • allMembers

      List<EPerson> allMembers(Context context, Group group) throws SQLException
      Get all of the EPerson objects who are a member of the specified group, or a member of a subgroup of the specified group, etc.

      WARNING: This method may have bad performance for Groups with a very large number of members, as it will load all member EPerson objects into memory. Only use if you need access to *every* EPerson object at once.

      Parameters:
      context - The relevant DSpace Context.
      group - Group object
      Returns:
      List of EPerson objects
      Throws:
      SQLException - if error
    • countAllMembers

      int countAllMembers(Context context, Group group) throws SQLException
      Count all of the EPerson objects who are a member of the specified group, or a member of a subgroup of the specified group, etc. In other words, this will return the size of "allMembers()" without having to load all EPerson objects into memory.
      Parameters:
      context - current DSpace context
      group - Group object
      Returns:
      count of EPerson object members
      Throws:
      SQLException - if error
    • findByName

      Group findByName(Context context, String name) throws SQLException
      Find the group by its name - assumes name is unique
      Parameters:
      context - The relevant DSpace Context.
      name - Group name to search for
      Returns:
      the named Group, or null if not found
      Throws:
      SQLException - if error
    • findAll

      List<Group> findAll(Context context, List<MetadataField> metadataSortFields, int pageSize, int offset) throws SQLException
      Finds all groups in the site
      Parameters:
      context - The relevant DSpace Context.
      metadataSortFields - metadata fields to sort by, leave empty to sort by Name
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      List of all groups in the site
      Throws:
      SQLException - if error
    • findAll

      @Deprecated List<Group> findAll(Context context, List<MetadataField> metadataSortFields) throws SQLException
      Deprecated.
      Please use findAll(Context context, List<MetadataField> metadataFieldsSort, int pageSize, int offset) instead
      Parameters:
      context - The relevant DSpace Context.
      metadataSortFields - metadata fields to sort by, leave empty to sort by Name
      Returns:
      List of all groups in the site
      Throws:
      SQLException - if error
    • findAll

      @Deprecated List<Group> findAll(Context context, int sortField) throws SQLException
      Deprecated.
      DEPRECATED: Please use findAll(Context context, List<MetadataField> metadataFieldsSort) instead
      Parameters:
      context - DSpace context
      sortField - sort field index
      Returns:
      List of all groups in the site
      Throws:
      SQLException - if error
    • search

      List<Group> search(Context context, String query) throws SQLException
      Find the Groups that match the query across both Group name and Group ID. This is an unpaginated search, which means it will load all matching groups into memory at once. This may provide POOR PERFORMANCE when a large number of groups are matched.
      Parameters:
      context - DSpace context
      query - The search string used to search across group name or group ID
      Returns:
      List of matching Group objects
      Throws:
      SQLException - if error
    • search

      List<Group> search(Context context, String query, int offset, int limit) throws SQLException
      Find the Groups that match the query across both Group name and Group ID. This method supports pagination, which provides better performance than the above non-paginated search() method.
      Parameters:
      context - DSpace context
      query - The search string used to search across group name or group ID
      offset - Inclusive offset (the position of the first result to return)
      limit - Maximum number of matches returned
      Returns:
      List of matching Group objects
      Throws:
      SQLException - if error
    • searchResultCount

      int searchResultCount(Context context, String query) throws SQLException
      Returns the total number of Groups returned by a specific query. Search is performed based on Group name and Group ID. May be used with search() above to support pagination of matching Groups.
      Parameters:
      context - DSpace context
      query - The search string used to search across group name or group ID
      Returns:
      the number of groups matching the query
      Throws:
      SQLException - if error
    • searchNonMembers

      List<Group> searchNonMembers(Context context, String query, Group excludeParentGroup, int offset, int limit) throws SQLException
      Find the groups that match the search query which are NOT currently members (subgroups) of the given parentGroup
      Parameters:
      context - DSpace context
      query - The search string used to search across group name or group ID
      excludeParentGroup - Parent group to exclude results from
      offset - Inclusive offset (the position of the first result to return)
      limit - Maximum number of matches returned
      Returns:
      List of matching Group objects
      Throws:
      SQLException - if error
    • searchNonMembersCount

      int searchNonMembersCount(Context context, String query, Group excludeParentGroup) throws SQLException
      Returns the total number of groups that match the search query which are NOT currently members (subgroups) of the given parentGroup. Can be used with searchNonMembers() to support pagination.
      Parameters:
      context - DSpace context
      query - The search string used to search across group name or group ID
      excludeParentGroup - Parent group to exclude results from
      Returns:
      the number of Groups matching the query
      Throws:
      SQLException - if error
    • isEmpty

      boolean isEmpty(Group group)
      Return true if group has no direct or indirect members
      Parameters:
      group - DSpace group
      Returns:
      true or false
    • initDefaultGroupNames

      void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException
      Initializes the group names for anonymous and administrator, and marks them "permanent".
      Parameters:
      context - the DSpace context
      Throws:
      SQLException - database exception
      AuthorizeException - authorization error
    • getEmptyGroups

      List<Group> getEmptyGroups(Context context) throws SQLException
      Find all empty groups in DSpace
      Parameters:
      context - The DSpace context
      Returns:
      All empty groups
      Throws:
      SQLException - database exception
    • countTotal

      int countTotal(Context context) throws SQLException
      Count the total number of groups in DSpace
      Parameters:
      context - The DSpace context
      Returns:
      The total number of groups
      Throws:
      SQLException - database exception
    • findByMetadataField

      List<Group> findByMetadataField(Context context, String searchValue, MetadataField metadataField) throws SQLException
      Look up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)
      Parameters:
      context - The DSpace context
      searchValue - The value to match
      metadataField - The metadata field to search in
      Returns:
      The groups that have a matching value for specified metadata field
      Throws:
      SQLException - database exception
    • findByParent

      List<Group> findByParent(Context context, Group parent, int pageSize, int offset) throws SQLException
      Find all groups which are a member of the given Parent group
      Parameters:
      context - The relevant DSpace Context.
      parent - The parent Group to search on
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      List of all groups which are members of the parent group
      Throws:
      SQLException - database exception if error
    • countByParent

      int countByParent(Context context, Group parent) throws SQLException
      Return number of groups which are a member of the given Parent group. Can be used with findByParent() for pagination of all groups within a given Parent group.
      Parameters:
      context - The relevant DSpace Context.
      parent - The parent Group to search on
      Returns:
      number of groups which are members of the parent group
      Throws:
      SQLException - database exception if error