Package org.dspace.eperson
Class EPersonServiceImpl
- java.lang.Object
-
- org.dspace.content.DSpaceObjectServiceImpl<EPerson>
-
- org.dspace.eperson.EPersonServiceImpl
-
- All Implemented Interfaces:
DSpaceObjectLegacySupportService<EPerson>,DSpaceObjectService<EPerson>,EPersonService
public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> implements EPersonService
Service implementation for the EPerson object. This class is responsible for all business logic calls for the EPerson object and is autowired by spring. This class should never be accessed directly.- Author:
- kevinvandevelde at atmire.com
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected ClaimedTaskServiceclaimedTaskServiceprotected ConfigurationServiceconfigurationServiceprotected EPersonDAOePersonDAOprotected GroupServicegroupServiceprotected ItemServiceitemServiceprotected OrcidTokenServiceorcidTokenServiceprotected SubscribeServicesubscribeServiceprotected VersionDAOversionDAOprotected WorkflowItemRoleServiceworkflowItemRoleService-
Fields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipService
-
Fields inherited from interface org.dspace.content.service.DSpaceObjectService
MD_COPYRIGHT_TEXT, MD_INTRODUCTORY_TEXT, MD_LICENSE, MD_NAME, MD_PROVENANCE_DESCRIPTION, MD_SHORT_DESCRIPTION, MD_SIDEBAR_TEXT, MD_SOURCE, MD_USER_FORMAT_DESCRIPTION
-
Fields inherited from interface org.dspace.eperson.service.EPersonService
MD_FIRSTNAME, MD_LANGUAGE, MD_LASTNAME, MD_PHONE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedEPersonServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckPassword(Context context, EPerson ePerson, String attempt)Check EPerson's password.intcountByGroups(Context c, Set<Group> groups)Count all EPerson accounts which belong to at least one of the specified groups.intcountTotal(Context context)Count all accounts.EPersoncreate(Context context)Create a new epersonvoiddelete(Context context, EPerson ePerson)voiddelete(Context context, EPerson ePerson, boolean cascade)Deletes an EPerson.EPersonfind(Context context, UUID id)Generic find for when the precise type of an Entity is not knownList<EPerson>findAll(Context context, int sortField)Find all theEPersons in a specific order by field.List<EPerson>findAll(Context context, int sortField, int pageSize, int offset)Find all theEPersons in a specific order by field.EPersonfindByEmail(Context context, String email)Find the eperson by their email address.List<EPerson>findByGroups(Context c, Set<Group> groups)Retrieve all EPerson accounts which belong to at least one of the specified groups.List<EPerson>findByGroups(Context c, Set<Group> groups, int pageSize, int offset)Retrieve all EPerson accounts which belong to at least one of the specified groups, in a paginated fashion.EPersonfindByIdOrLegacyId(Context context, String id)EPersonfindByLegacyId(Context context, int legacyId)Generic find for when the precise type of a DSO is not known, just the a pair of type number and database ID.EPersonfindByNetid(Context context, String netId)Find the eperson by their netid.EPersonfindByProfileItem(Context context, Item profile)Find the EPerson related to the given profile item.List<EPerson>findEPeopleWithSubscription(Context context)Retrieve all accounts which are subscribed to receive information about new items.List<EPerson>findNotActiveSince(Context context, Date date)Retrieve all accounts which have not logged in since the specified dateList<EPerson>findUnsalted(Context context)Retrieve all accounts which have a password but do not have a digest algorithmList<String>getDeleteConstraints(Context context, EPerson ePerson)Check for presence of EPerson in tables that have constraints on EPersons.StringgetMetadata(EPerson dso, String field)Get the value of a metadata fieldStringgetName(EPerson dso)Get a proper name for the object.PasswordHashgetPasswordHash(EPerson ePerson)Return the EPerson's password hash.intgetSupportsTypeConstant()Returns the Constants which this service supportsEPersongetSystemEPerson(Context c)Create a fake EPerson which can receive email.List<EPerson>search(Context context, String query)Find the epeople that match the search query across firstname, lastname or email.List<EPerson>search(Context context, String query, int offset, int limit)Find the epeople that match the search query across firstname, lastname or email.List<EPerson>searchNonMembers(Context context, String query, Group excludeGroup, int offset, int limit)Find the EPersons that match the search query which are NOT currently members of the given Group.intsearchNonMembersCount(Context context, String query, Group excludeGroup)Returns the total number of EPersons that match the search query which are NOT currently members of the given Group.intsearchResultCount(Context context, String query)Returns the total number of epeople returned by a specific query, without the overhead of creating the EPerson objects to store the results.voidsetPassword(EPerson ePerson, String password)Set the EPerson's password.voidsetPasswordHash(EPerson ePerson, PasswordHash password)Set the EPerson's password hash.voidupdate(Context context, EPerson ePerson)voidupdateLastModified(Context context, EPerson dso)-
Methods inherited from class org.dspace.content.DSpaceObjectServiceImpl
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getMetadataValuePlace, getParentObject, getTypeText, match, moveMetadata, moveSingleMetadataValue, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getParentObject, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
-
-
-
Field Detail
-
ePersonDAO
@Autowired(required=true) protected EPersonDAO ePersonDAO
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
itemService
@Autowired(required=true) protected ItemService itemService
-
workflowItemRoleService
@Autowired(required=true) protected WorkflowItemRoleService workflowItemRoleService
-
groupService
@Autowired(required=true) protected GroupService groupService
-
subscribeService
@Autowired(required=true) protected SubscribeService subscribeService
-
versionDAO
@Autowired(required=true) protected VersionDAO versionDAO
-
claimedTaskService
@Autowired(required=true) protected ClaimedTaskService claimedTaskService
-
configurationService
@Autowired(required=true) protected ConfigurationService configurationService
-
orcidTokenService
@Autowired protected OrcidTokenService orcidTokenService
-
-
Method Detail
-
find
public EPerson find(Context context, UUID id) throws SQLException
Description copied from interface:DSpaceObjectServiceGeneric find for when the precise type of an Entity is not known- Specified by:
findin interfaceDSpaceObjectService<EPerson>- Parameters:
context- - the contextid- - uuid within table of typed dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
getSystemEPerson
public EPerson getSystemEPerson(Context c) throws SQLException
Create a fake EPerson which can receive email. Its address will be the value of "mail.admin", or "postmaster" if all else fails.- Specified by:
getSystemEPersonin interfaceEPersonService- Parameters:
c-- Returns:
- Throws:
SQLException
-
findByIdOrLegacyId
public EPerson findByIdOrLegacyId(Context context, String id) throws SQLException
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<EPerson>- Throws:
SQLException
-
findByLegacyId
public EPerson findByLegacyId(Context context, int legacyId) throws SQLException
Description copied from interface:DSpaceObjectLegacySupportServiceGeneric find for when the precise type of a DSO is not known, just the a pair of type number and database ID.- Specified by:
findByLegacyIdin interfaceDSpaceObjectLegacySupportService<EPerson>- Parameters:
context- - the contextlegacyId- - the legacy id within table of type'd objects- Returns:
- the object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
findByEmail
public EPerson findByEmail(Context context, String email) throws SQLException
Description copied from interface:EPersonServiceFind the eperson by their email address.- Specified by:
findByEmailin interfaceEPersonService- Parameters:
context- The relevant DSpace Context.email- EPerson's email to search by- Returns:
- EPerson, or
nullif none such exists. - Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
findByNetid
public EPerson findByNetid(Context context, String netId) throws SQLException
Description copied from interface:EPersonServiceFind the eperson by their netid.- Specified by:
findByNetidin interfaceEPersonService- 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
public List<EPerson> search(Context context, String query) throws SQLException
Description copied from interface:EPersonServiceFind the epeople that match the search query across firstname, lastname or email.- Specified by:
searchin interfaceEPersonService- 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
public List<EPerson> search(Context context, String query, int offset, int limit) throws SQLException
Description copied from interface:EPersonServiceFind the epeople that match the search query across firstname, lastname or email. This method also allows offsets and limits for pagination purposes.- Specified by:
searchin interfaceEPersonService- Parameters:
context- The relevant DSpace Context.query- The search stringoffset- 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
public int searchResultCount(Context context, String query) throws SQLException
Description copied from interface:EPersonServiceReturns the total number of epeople returned by a specific query, without the overhead of creating the EPerson objects to store the results.- Specified by:
searchResultCountin interfaceEPersonService- 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
public List<EPerson> searchNonMembers(Context context, String query, Group excludeGroup, int offset, int limit) throws SQLException
Description copied from interface:EPersonServiceFind 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.- Specified by:
searchNonMembersin interfaceEPersonService- Parameters:
context- DSpace contextquery- The search stringexcludeGroup- 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
public int searchNonMembersCount(Context context, String query, Group excludeGroup) throws SQLException
Description copied from interface:EPersonServiceReturns 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- Specified by:
searchNonMembersCountin interfaceEPersonService- Parameters:
context- DSpace contextquery- The search stringexcludeGroup- Group to exclude results from. Members of this group will never be returned.- Returns:
- List of matching EPerson objects
- Throws:
SQLException- if error
-
findAll
public List<EPerson> findAll(Context context, int sortField) throws SQLException
Description copied from interface:EPersonServiceFind all theEPersons in a specific order by field. The sortable fields are:IDLASTNAMEEMAILNETID
- Specified by:
findAllin interfaceEPersonService- 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
public List<EPerson> findAll(Context context, int sortField, int pageSize, int offset) throws SQLException
Description copied from interface:EPersonServiceFind all theEPersons in a specific order by field. The sortable fields are:IDLASTNAMEEMAILNETID
- Specified by:
findAllin interfaceEPersonService- Parameters:
context- The relevant DSpace Context.sortField- which field to sort EPersons bypageSize- how many results returnoffset- 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.
-
create
public EPerson create(Context context) throws SQLException, AuthorizeException
Description copied from interface:EPersonServiceCreate a new eperson- Specified by:
createin interfaceEPersonService- 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.
-
delete
public void delete(Context context, EPerson ePerson) throws SQLException, AuthorizeException
- Specified by:
deletein interfaceDSpaceObjectService<EPerson>- Throws:
SQLExceptionAuthorizeException
-
delete
public void delete(Context context, EPerson ePerson, boolean cascade) throws SQLException, AuthorizeException, IOException, EPersonDeletionException
Deletes an EPerson. The argument cascade defines whether all references on an EPerson should be deleted as well (by either deleting the referencing object - e.g. WorkspaceItem, ResourcePolicy - or by setting the foreign key null - e.g. archived Items). If cascade is set to false and the EPerson is referenced somewhere, this leads to an AuthorizeException. EPersons may be referenced by Items, ResourcePolicies and workflow tasks.- Parameters:
context- DSpace contextePerson- The EPerson to delete.cascade- Whether to delete references on the EPerson (cascade = true) or to abort the deletion (cascade = false) if the EPerson is referenced within DSpace.- Throws:
SQLExceptionAuthorizeExceptionIOExceptionEPersonDeletionException
-
getSupportsTypeConstant
public int getSupportsTypeConstant()
Description copied from interface:DSpaceObjectServiceReturns the Constants which this service supports- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectLegacySupportService<EPerson>- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectService<EPerson>- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
setPassword
public void setPassword(EPerson ePerson, String password)
Description copied from interface:EPersonServiceSet the EPerson's password.- Specified by:
setPasswordin interfaceEPersonService- Parameters:
ePerson- EPerson whose password we want to set.password- the new password.
-
setPasswordHash
public void setPasswordHash(EPerson ePerson, PasswordHash password)
Description copied from interface:EPersonServiceSet the EPerson's password hash.- Specified by:
setPasswordHashin interfaceEPersonService- Parameters:
ePerson- EPerson whose password hash we want to set.password- hashed password, or null to set row data to NULL.
-
getPasswordHash
public PasswordHash getPasswordHash(EPerson ePerson)
Description copied from interface:EPersonServiceReturn the EPerson's password hash.- Specified by:
getPasswordHashin interfaceEPersonService- Parameters:
ePerson- EPerson whose password hash we want to get.- Returns:
- hash of the password, or null on failure (such as no password).
-
checkPassword
public boolean checkPassword(Context context, EPerson ePerson, String attempt)
Description copied from interface:EPersonServiceCheck EPerson's password. Side effect: original unsalted MD5 hashes are converted using the current algorithm.- Specified by:
checkPasswordin interfaceEPersonService- Parameters:
context- The relevant DSpace Context.ePerson- EPerson whose password we want to checkattempt- the password attempt- Returns:
- boolean successful/unsuccessful
-
update
public void update(Context context, EPerson ePerson) throws SQLException, AuthorizeException
- Specified by:
updatein interfaceDSpaceObjectService<EPerson>- Overrides:
updatein classDSpaceObjectServiceImpl<EPerson>- Throws:
SQLExceptionAuthorizeException
-
getDeleteConstraints
public List<String> getDeleteConstraints(Context context, EPerson ePerson) throws SQLException
Description copied from interface:EPersonServiceCheck 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.- Specified by:
getDeleteConstraintsin interfaceEPersonService- 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
public List<EPerson> findByGroups(Context c, Set<Group> groups) throws SQLException
Description copied from interface:EPersonServiceRetrieve 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.
- Specified by:
findByGroupsin interfaceEPersonService- 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
public List<EPerson> findByGroups(Context c, Set<Group> groups, int pageSize, int offset) throws SQLException
Description copied from interface:EPersonServiceRetrieve all EPerson accounts which belong to at least one of the specified groups, in a paginated fashion.- Specified by:
findByGroupsin interfaceEPersonService- Parameters:
c- The relevant DSpace Context.groups- Set of group(s) to check membership inpageSize- number of EPerson objects to load at one time. Set to <=0 to disable paginationoffset- 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
public int countByGroups(Context c, Set<Group> groups) throws SQLException
Description copied from interface:EPersonServiceCount 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.- Specified by:
countByGroupsin interfaceEPersonService- 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
public List<EPerson> findEPeopleWithSubscription(Context context) throws SQLException
Description copied from interface:EPersonServiceRetrieve all accounts which are subscribed to receive information about new items.- Specified by:
findEPeopleWithSubscriptionin interfaceEPersonService- 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.
-
updateLastModified
public void updateLastModified(Context context, EPerson dso) throws SQLException
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<EPerson>- Throws:
SQLException
-
getMetadata
public String getMetadata(EPerson dso, String field)
Description copied from interface:DSpaceObjectServiceGet the value of a metadata field- Specified by:
getMetadatain interfaceDSpaceObjectService<EPerson>- Overrides:
getMetadatain classDSpaceObjectServiceImpl<EPerson>- Parameters:
dso- DSpaceObjectfield- the name of the metadata field to get- Returns:
- the value of the metadata field (or null if the column is an SQL NULL)
-
findUnsalted
public List<EPerson> findUnsalted(Context context) throws SQLException
Description copied from interface:EPersonServiceRetrieve all accounts which have a password but do not have a digest algorithm- Specified by:
findUnsaltedin interfaceEPersonService- 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
public List<EPerson> findNotActiveSince(Context context, Date date) throws SQLException
Description copied from interface:EPersonServiceRetrieve all accounts which have not logged in since the specified date- Specified by:
findNotActiveSincein interfaceEPersonService- 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.
-
countTotal
public int countTotal(Context context) throws SQLException
Description copied from interface:EPersonServiceCount all accounts.- Specified by:
countTotalin interfaceEPersonService- 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
public EPerson findByProfileItem(Context context, Item profile) throws SQLException
Description copied from interface:EPersonServiceFind the EPerson related to the given profile item. If the given item is not a profile item, null is returned.- Specified by:
findByProfileItemin interfaceEPersonService- 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.
-
getName
public String getName(EPerson dso)
Description copied from interface:DSpaceObjectServiceGet a proper name for the object. This may returnnull. Name should be suitable for display in a user interface.- Specified by:
getNamein interfaceDSpaceObjectService<EPerson>- Overrides:
getNamein classDSpaceObjectServiceImpl<EPerson>- Parameters:
dso- DSpaceObject- Returns:
- Name for the object, or
nullif it doesn't have one
-
-