Interface EPersonService

All Superinterfaces:
DSpaceObjectLegacySupportService<EPerson>, DSpaceObjectService<EPerson>
All Known Implementing Classes:
EPersonServiceImpl

public interface EPersonService extends DSpaceObjectService<EPerson>, DSpaceObjectLegacySupportService<EPerson>
Service interface class for the EPerson object. The implementation of this class is responsible for all business logic calls for the EPerson object and is autowired by Spring.

Methods for handling registration by email and forgotten passwords. When someone registers as a user, or forgets their password, the sendRegistrationInfo or sendForgotPasswordInfo methods can be used to send an email to the user. The email contains a special token, a long string which is randomly generated and thus hard to guess. When the user presents the token back to the system, the AccountManager can use the token to determine the identity of the eperson.

*NEW* now ignores expiration dates so that tokens never expire.

Author:
Peter Breton, kevinvandevelde at atmire.com
  • Field Details

  • Method Details

    • findByEmail

      EPerson findByEmail(Context context, String email) throws SQLException
      Find the eperson by their email address.
      Parameters:
      context - The relevant DSpace Context.
      email - EPerson's email to search by
      Returns:
      EPerson, or null if none such exists.
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findByNetid

      EPerson findByNetid(Context context, String netId) throws SQLException
      Find the eperson by their netid.
      Parameters:
      context - The relevant DSpace Context.
      netId - Network ID
      Returns:
      corresponding EPerson, or null
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • search

      List<EPerson> search(Context context, String query) throws SQLException
      Find the epeople that match the search query across firstname, lastname or email.
      Parameters:
      context - The relevant DSpace Context.
      query - The search string
      Returns:
      array of EPerson objects
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • search

      List<EPerson> search(Context context, String query, int offset, int limit) throws SQLException
      Find the epeople that match the search query across firstname, lastname or email. This method also allows offsets and limits for pagination purposes.
      Parameters:
      context - The relevant DSpace Context.
      query - The search string
      offset - Inclusive offset (the position of the first result to return)
      limit - Maximum number of matches returned
      Returns:
      List of matching EPerson objects
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • searchResultCount

      int searchResultCount(Context context, String query) throws SQLException
      Returns the total number of epeople returned by a specific query, without the overhead of creating the EPerson objects to store the results.
      Parameters:
      context - The relevant DSpace Context.
      query - The search string
      Returns:
      the number of epeople matching the query
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • searchNonMembers

      List<EPerson> searchNonMembers(Context context, String query, Group excludeGroup, int offset, int limit) throws SQLException
      Find the EPersons that match the search query which are NOT currently members of the given Group. The search query is run against firstname, lastname or email.
      Parameters:
      context - DSpace context
      query - The search string
      excludeGroup - Group to exclude results from. Members of this group will never be returned.
      offset - Inclusive offset (the position of the first result to return)
      limit - Maximum number of matches returned
      Returns:
      List of matching EPerson objects
      Throws:
      SQLException - if error
    • searchNonMembersCount

      int searchNonMembersCount(Context context, String query, Group excludeGroup) throws SQLException
      Returns the total number of EPersons that match the search query which are NOT currently members of the given Group. The search query is run against firstname, lastname or email. Can be used with searchNonMembers() to support pagination
      Parameters:
      context - DSpace context
      query - The search string
      excludeGroup - Group to exclude results from. Members of this group will never be returned.
      Returns:
      List of matching EPerson objects
      Throws:
      SQLException - if error
    • findAll

      @Deprecated List<EPerson> findAll(Context context, int sortField) throws SQLException
      Deprecated.
      use the paginated method findAll(org.dspace.core.Context,int).
      Find all the EPersons in a specific order by field. The sortable fields are:
      • ID
      • LASTNAME
      • EMAIL
      • NETID
      Parameters:
      context - The relevant DSpace Context.
      sortField - which field to sort EPersons by
      Returns:
      list of EPerson objects
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findAll

      List<EPerson> findAll(Context context, int sortField, int pageSize, int offset) throws SQLException
      Find all the EPersons in a specific order by field. The sortable fields are:
      • ID
      • LASTNAME
      • EMAIL
      • NETID
      Parameters:
      context - The relevant DSpace Context.
      sortField - which field to sort EPersons by
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      list of EPerson objects
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • getSystemEPerson

      @NotNull @NotNull EPerson getSystemEPerson(Context context) throws SQLException
      The "System EPerson" is a fake account that exists only to receive email. It has an email address that should be presumed usable. It does not exist in the database and is not complete.
      Parameters:
      context - current DSpace session.
      Returns:
      an EPerson that can presumably receive email.
      Throws:
      SQLException
    • create

      Create a new eperson
      Parameters:
      context - The relevant DSpace Context.
      Returns:
      the created EPerson
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
      AuthorizeException - Exception indicating the current user of the context does not have permission to perform a particular action.
    • setPassword

      void setPassword(EPerson ePerson, String password)
      Set the EPerson's password.
      Parameters:
      ePerson - EPerson whose password we want to set.
      password - the new password.
    • setPasswordHash

      void setPasswordHash(EPerson ePerson, PasswordHash password)
      Set the EPerson's password hash.
      Parameters:
      ePerson - EPerson whose password hash we want to set.
      password - hashed password, or null to set row data to NULL.
    • getPasswordHash

      PasswordHash getPasswordHash(EPerson ePerson)
      Return the EPerson's password hash.
      Parameters:
      ePerson - EPerson whose password hash we want to get.
      Returns:
      hash of the password, or null on failure (such as no password).
    • checkPassword

      boolean checkPassword(Context context, EPerson ePerson, String attempt)
      Check EPerson's password. Side effect: original unsalted MD5 hashes are converted using the current algorithm.
      Parameters:
      context - The relevant DSpace Context.
      ePerson - EPerson whose password we want to check
      attempt - the password attempt
      Returns:
      boolean successful/unsuccessful
    • findUnsalted

      List<EPerson> findUnsalted(Context context) throws SQLException
      Retrieve all accounts which have a password but do not have a digest algorithm
      Parameters:
      context - The relevant DSpace Context.
      Returns:
      a list of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findNotActiveSince

      List<EPerson> findNotActiveSince(Context context, Instant date) throws SQLException
      Retrieve all accounts which have not logged in since the specified date
      Parameters:
      context - The relevant DSpace Context.
      date - from which date
      Returns:
      a list of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • getDeleteConstraints

      List<String> getDeleteConstraints(Context context, EPerson ePerson) throws SQLException
      Check for presence of EPerson in tables that have constraints on EPersons. Called by delete() to determine whether the eperson can actually be deleted. An EPerson cannot be deleted if it exists in the item, resourcepolicy or workflow-related tables.
      Parameters:
      context - The relevant DSpace Context.
      ePerson - EPerson to find
      Returns:
      List of tables that contain a reference to the eperson.
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findByGroups

      List<EPerson> findByGroups(Context c, Set<Group> groups) throws SQLException
      Retrieve all EPerson accounts which belong to at least one of the specified groups.

      WARNING: This method may have bad performance issues for Groups with a very large number of members, as it will load all member EPerson objects into memory.

      For better performance, use the paginated version of this method.

      Parameters:
      c - The relevant DSpace Context.
      groups - set of eperson groups
      Returns:
      a list of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findByGroups

      List<EPerson> findByGroups(Context c, Set<Group> groups, int pageSize, int offset) throws SQLException
      Retrieve all EPerson accounts which belong to at least one of the specified groups, in a paginated fashion.
      Parameters:
      c - The relevant DSpace Context.
      groups - Set of group(s) to check membership in
      pageSize - number of EPerson objects to load at one time. Set to <=0 to disable pagination
      offset - number of page to load (starting with 1). Set to <=0 to disable pagination
      Returns:
      a list of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • countByGroups

      int countByGroups(Context c, Set<Group> groups) throws SQLException
      Count all EPerson accounts which belong to at least one of the specified groups. This provides the total number of results to expect from corresponding findByGroups() for pagination purposes.
      Parameters:
      c - The relevant DSpace Context.
      groups - Set of group(s) to check membership in
      Returns:
      total number of (unique) EPersons who are a member of one or more groups.
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findEPeopleWithSubscription

      List<EPerson> findEPeopleWithSubscription(Context context) throws SQLException
      Retrieve all accounts which are subscribed to receive information about new items.
      Parameters:
      context - The relevant DSpace Context.
      Returns:
      a list of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • countTotal

      int countTotal(Context context) throws SQLException
      Count all accounts.
      Parameters:
      context - The relevant DSpace Context.
      Returns:
      the total number of epeople
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.
    • findByProfileItem

      EPerson findByProfileItem(Context context, Item profile) throws SQLException
      Find the EPerson related to the given profile item. If the given item is not a profile item, null is returned.
      Parameters:
      context - The relevant DSpace Context.
      profile - the profile item to search for
      Returns:
      the EPerson, if any
      Throws:
      SQLException - An exception that provides information on a database access error or other errors.