Package org.dspace.eperson
Class GroupServiceImpl
- java.lang.Object
-
- org.dspace.content.DSpaceObjectServiceImpl<Group>
-
- org.dspace.eperson.GroupServiceImpl
-
- All Implemented Interfaces:
DSpaceObjectLegacySupportService<Group>,DSpaceObjectService<Group>,GroupService
public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements GroupService
Service implementation for the Group object. This class is responsible for all business logic calls for the Group 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 CollectionRoleServicecollectionRoleServiceprotected CollectionServicecollectionServiceprotected CommunityServicecommunityServiceprotected EPersonServiceePersonServiceprotected Group2GroupCacheDAOgroup2GroupCacheDAOprotected GroupDAOgroupDAO-
Fields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipService
-
Fields inherited from interface org.dspace.eperson.service.GroupService
NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGroupServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMember(Context context, Group group, EPerson e)add an eperson membervoidaddMember(Context context, Group groupParent, Group groupChild)add group to this groupList<Group>allMemberGroups(Context context, EPerson ePerson)Get all of the groups that an eperson is a member of.Set<Group>allMemberGroupsSet(Context context, EPerson ePerson)List<EPerson>allMembers(Context c, Group g)Get all of the epeople who are a member of the specified group, or a member of a sub-group of the specified group, etc.intcountTotal(Context context)Count the total number of groups in DSpaceGroupcreate(Context context)Create a new groupvoiddelete(Context context, Group group)Groupfind(Context context, UUID id)Generic find for when the precise type of an Entity is not knownList<Group>findAll(Context context, int sortField)Deprecated.List<Group>findAll(Context context, List<MetadataField> metadataSortFields)List<Group>findAll(Context context, List<MetadataField> metadataSortFields, int pageSize, int offset)Finds all groups in the siteGroupfindByIdOrLegacyId(Context context, String id)GroupfindByLegacyId(Context context, int id)Generic find for when the precise type of a DSO is not known, just the a pair of type number and database ID.List<Group>findByMetadataField(Context context, String searchValue, MetadataField metadataField)Look up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)GroupfindByName(Context context, String name)Find the group by its name - assumes name is uniqueprotected Set<UUID>getChildren(Map<UUID,Set<UUID>> parents, UUID parent)Used recursively to generate a map of ALL of the children of the given parentList<Group>getEmptyGroups(Context context)Get a list of groups with no members.DSpaceObjectgetParentObject(Context context, Group group)Return the dspace object that "own" the current object in the hierarchy.intgetSupportsTypeConstant()Returns the Constants which this service supportsvoidinitDefaultGroupNames(Context context)Initializes the group names for anonymous and administrator, and marks them "permanent".booleanisDirectMember(Group group, EPerson ePerson)check to see if an eperson is a direct member.booleanisEmpty(Group group)Return true if group has no direct or indirect membersprotected booleanisEPersonInGroup(Context context, Group group, EPerson ePerson)booleanisMember(Context context, String groupName)fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method.booleanisMember(Context context, EPerson eperson, String groupName)fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method.booleanisMember(Context context, EPerson ePerson, Group group)fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static methodbooleanisMember(Context context, Group group)fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static methodbooleanisMember(Group owningGroup, Group childGroup)Check to see if childGroup is a direct group member of owningGroup.booleanisParentOf(Context context, Group parentGroup, Group childGroup)Check to see if parentGroup is a direct or in-direct parent of a childGroup.voidremoveMember(Context context, Group group, EPerson ePerson)remove an eperson from a groupvoidremoveMember(Context context, Group groupParent, Group childGroup)remove group from this groupprotected voidrethinkGroupCache(Context context, boolean flushQueries)Regenerate the group cache AKA the group2groupcache table in the database - meant to be called when a group is added or removed from another groupList<Group>search(Context context, String groupIdentifier)Find the groups that match the search query across eperson_group_id or nameList<Group>search(Context context, String groupIdentifier, int offset, int limit)Find the groups that match the search query across eperson_group_id or nameintsearchResultCount(Context context, String groupIdentifier)Returns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.voidsetName(Group group, String name)set name of groupvoidupdate(Context context, Group group)Update the group - writing out group object and EPerson list if necessaryvoidupdateLastModified(Context context, Group dso)-
Methods inherited from class org.dspace.content.DSpaceObjectServiceImpl
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataValuePlace, getName, getTypeText, match, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, 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, clearMetadata, getAdminObject, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getName, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue
-
-
-
-
Field Detail
-
groupDAO
@Autowired(required=true) protected GroupDAO groupDAO
-
group2GroupCacheDAO
@Autowired(required=true) protected Group2GroupCacheDAO group2GroupCacheDAO
-
collectionService
@Autowired(required=true) protected CollectionService collectionService
-
collectionRoleService
@Autowired(required=true) protected CollectionRoleService collectionRoleService
-
ePersonService
@Autowired(required=true) protected EPersonService ePersonService
-
communityService
@Autowired(required=true) protected CommunityService communityService
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
-
Method Detail
-
create
public Group create(Context context) throws SQLException, AuthorizeException
Description copied from interface:GroupServiceCreate a new group- Specified by:
createin interfaceGroupService- Parameters:
context- DSpace context object- Returns:
- group
- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
setName
public void setName(Group group, String name) throws SQLException
Description copied from interface:GroupServiceset name of group- Specified by:
setNamein interfaceGroupService- Parameters:
group- DSpace groupname- new group name- Throws:
SQLException- if database error
-
addMember
public void addMember(Context context, Group group, EPerson e)
Description copied from interface:GroupServiceadd an eperson member- Specified by:
addMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroup- DSpace groupe- eperson
-
addMember
public void addMember(Context context, Group groupParent, Group groupChild) throws SQLException
Description copied from interface:GroupServiceadd group to this group- Specified by:
addMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroupParent- parent groupgroupChild- child group- Throws:
SQLException- if database error
-
removeMember
public void removeMember(Context context, Group group, EPerson ePerson)
Description copied from interface:GroupServiceremove an eperson from a group- Specified by:
removeMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroup- DSpace groupePerson- eperson
-
removeMember
public void removeMember(Context context, Group groupParent, Group childGroup) throws SQLException
Description copied from interface:GroupServiceremove group from this group- Specified by:
removeMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroupParent- parent groupchildGroup- child group- Throws:
SQLException- if database error
-
isDirectMember
public boolean isDirectMember(Group group, EPerson ePerson)
Description copied from interface:GroupServicecheck to see if an eperson is a direct member. If the eperson is a member via a subgroup will be returnedfalse- Specified by:
isDirectMemberin interfaceGroupService- Parameters:
group- DSpace groupePerson- eperson to check membership- Returns:
- true or false
-
isMember
public boolean isMember(Group owningGroup, Group childGroup)
Description copied from interface:GroupServiceCheck to see if childGroup is a direct group member of owningGroup. If childGroup is a subgroup via another group will be returnedfalse- Specified by:
isMemberin interfaceGroupService- Parameters:
owningGroup- parent groupchildGroup- child group- Returns:
- true or false
-
isParentOf
public boolean isParentOf(Context context, Group parentGroup, Group childGroup) throws SQLException
Description copied from interface:GroupServiceCheck to see if parentGroup is a direct or in-direct parent of a childGroup.- Specified by:
isParentOfin interfaceGroupServiceparentGroup- parent groupchildGroup- child group- Returns:
- true or false
- Throws:
SQLException
-
isMember
public boolean isMember(Context context, Group group) throws SQLException
Description copied from interface:GroupServicefast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method- Specified by:
isMemberin interfaceGroupService- Parameters:
context- contextgroup- group to check- Returns:
- true or false
- Throws:
SQLException- if database error
-
isMember
public boolean isMember(Context context, EPerson ePerson, Group group) throws SQLException
Description copied from interface:GroupServicefast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method- Specified by:
isMemberin interfaceGroupService- Parameters:
context- DSpace context object.ePerson- EPerson whos membership should be checked.group- The group to check against.- Returns:
- true or false
- Throws:
SQLException- if database error
-
isMember
public boolean isMember(Context context, String groupName) throws SQLException
Description copied from interface:GroupServicefast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method. This method uses context.getCurrentUser() as eperson whos membership should be checked.- Specified by:
isMemberin interfaceGroupService- Parameters:
context- contextgroupName- the name of the group to check- Returns:
- true or false
- Throws:
SQLException- if database error
-
isMember
public boolean isMember(Context context, EPerson eperson, String groupName) throws SQLException
Description copied from interface:GroupServicefast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method. The eperson whos membership should be checked must be defined as method attribute.- Specified by:
isMemberin interfaceGroupService- Parameters:
context- contextgroupName- the name of the group to check- Returns:
- true or false
- Throws:
SQLException- if database error
-
allMemberGroups
public List<Group> allMemberGroups(Context context, EPerson ePerson) throws SQLException
Description copied from interface:GroupServiceGet all of the groups that an eperson is a member of.- Specified by:
allMemberGroupsin interfaceGroupService- Parameters:
context- DSpace contenxtePerson- ePerson object- Returns:
- list of Group objects
- Throws:
SQLException- if database error
-
allMemberGroupsSet
public Set<Group> allMemberGroupsSet(Context context, EPerson ePerson) throws SQLException
- Specified by:
allMemberGroupsSetin interfaceGroupService- Throws:
SQLException
-
allMembers
public List<EPerson> allMembers(Context c, Group g) throws SQLException
Description copied from interface:GroupServiceGet all of the epeople who are a member of the specified group, or a member of a sub-group of the specified group, etc.- Specified by:
allMembersin interfaceGroupService- Parameters:
c- The relevant DSpace Context.g- Group object- Returns:
- List of EPerson objects
- Throws:
SQLException- if error
-
find
public Group 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<Group>- Parameters:
context- - the contextid- - uuid within table of type'd dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
findByName
public Group findByName(Context context, String name) throws SQLException
Description copied from interface:GroupServiceFind the group by its name - assumes name is unique- Specified by:
findByNamein interfaceGroupService- 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
@Deprecated public List<Group> findAll(Context context, int sortField) throws SQLException
Deprecated.DEPRECATED: Please usefindAll(Context context, List<MetadataField> metadataSortFields)instead- Specified by:
findAllin interfaceGroupService- Parameters:
context- DSpace contextsortField- sort field index- Returns:
- List of all groups in the site
- Throws:
SQLException- if error
-
findAll
public List<Group> findAll(Context context, List<MetadataField> metadataSortFields) throws SQLException
- Specified by:
findAllin interfaceGroupService- 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
public List<Group> findAll(Context context, List<MetadataField> metadataSortFields, int pageSize, int offset) throws SQLException
Description copied from interface:GroupServiceFinds all groups in the site- Specified by:
findAllin interfaceGroupService- Parameters:
context- The relevant DSpace Context.metadataSortFields- metadata fields to sort by, leave empty to sort by NamepageSize- how many results returnoffset- the position of the first result to return- Returns:
- List of all groups in the site
- Throws:
SQLException- if error
-
search
public List<Group> search(Context context, String groupIdentifier) throws SQLException
Description copied from interface:GroupServiceFind the groups that match the search query across eperson_group_id or name- Specified by:
searchin interfaceGroupService- Parameters:
context- DSpace contextgroupIdentifier- The group name or group ID- Returns:
- array of Group objects
- Throws:
SQLException- if error
-
search
public List<Group> search(Context context, String groupIdentifier, int offset, int limit) throws SQLException
Description copied from interface:GroupServiceFind the groups that match the search query across eperson_group_id or name- Specified by:
searchin interfaceGroupService- Parameters:
context- DSpace contextgroupIdentifier- The group name or group IDoffset- Inclusive offsetlimit- Maximum number of matches returned- Returns:
- array of Group objects
- Throws:
SQLException- if error
-
searchResultCount
public int searchResultCount(Context context, String groupIdentifier) throws SQLException
Description copied from interface:GroupServiceReturns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.- Specified by:
searchResultCountin interfaceGroupService- Parameters:
context- DSpace contextgroupIdentifier- The search string- Returns:
- the number of groups matching the query
- Throws:
SQLException- if error
-
delete
public void delete(Context context, Group group) throws SQLException
- Specified by:
deletein interfaceDSpaceObjectService<Group>- Throws:
SQLException
-
getSupportsTypeConstant
public int getSupportsTypeConstant()
Description copied from interface:DSpaceObjectServiceReturns the Constants which this service supports- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectLegacySupportService<Group>- Specified by:
getSupportsTypeConstantin interfaceDSpaceObjectService<Group>- Returns:
- a org.dspace.core.Constants that represents a IndexableObject type
-
isEmpty
public boolean isEmpty(Group group)
Return true if group has no direct or indirect members- Specified by:
isEmptyin interfaceGroupService- Parameters:
group- DSpace group- Returns:
- true or false
-
initDefaultGroupNames
public void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException
Description copied from interface:GroupServiceInitializes the group names for anonymous and administrator, and marks them "permanent".- Specified by:
initDefaultGroupNamesin interfaceGroupService- Parameters:
context- the DSpace context- Throws:
SQLException- database exceptionAuthorizeException- authorization error
-
getEmptyGroups
public List<Group> getEmptyGroups(Context context) throws SQLException
Get a list of groups with no members.- Specified by:
getEmptyGroupsin interfaceGroupService- Parameters:
context- The relevant DSpace Context.- Returns:
- list of groups with no members
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
update
public void update(Context context, Group group) throws SQLException, AuthorizeException
Update the group - writing out group object and EPerson list if necessary- Specified by:
updatein interfaceDSpaceObjectService<Group>- Overrides:
updatein classDSpaceObjectServiceImpl<Group>- Parameters:
context- The relevant DSpace Context.group- Group to update- 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.
-
isEPersonInGroup
protected boolean isEPersonInGroup(Context context, Group group, EPerson ePerson) throws SQLException
- Throws:
SQLException
-
rethinkGroupCache
protected void rethinkGroupCache(Context context, boolean flushQueries) throws SQLException
Regenerate the group cache AKA the group2groupcache table in the database - meant to be called when a group is added or removed from another group- Parameters:
context- The relevant DSpace Context.flushQueries- flushQueries Flush all pending queries- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getParentObject
public DSpaceObject getParentObject(Context context, Group group) throws SQLException
Description copied from interface:DSpaceObjectServiceReturn the dspace object that "own" the current object in the hierarchy. Note that this method has a meaning slightly different from the getAdminObject because it is independent of the action but it is in a way related to it. It defines the "first" dspace object OTHER then the current one, where allowed ADMIN actions imply allowed ADMIN actions on the object self.- Specified by:
getParentObjectin interfaceDSpaceObjectService<Group>- Overrides:
getParentObjectin classDSpaceObjectServiceImpl<Group>- Parameters:
context- DSpace contextgroup- DSpaceObject- Returns:
- the dspace object that "own" the current object in the hierarchy
- Throws:
SQLException- if database error
-
updateLastModified
public void updateLastModified(Context context, Group dso)
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<Group>
-
getChildren
protected Set<UUID> getChildren(Map<UUID,Set<UUID>> parents, UUID parent)
Used recursively to generate a map of ALL of the children of the given parent- Parameters:
parents- Map of parent,child relationshipsparent- the parent you're interested in- Returns:
- Map whose keys are all of the children of a parent
-
findByIdOrLegacyId
public Group findByIdOrLegacyId(Context context, String id) throws SQLException
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<Group>- Throws:
SQLException
-
findByLegacyId
public Group findByLegacyId(Context context, int id) 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<Group>- Parameters:
context- - the contextid- - 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.
-
countTotal
public int countTotal(Context context) throws SQLException
Description copied from interface:GroupServiceCount the total number of groups in DSpace- Specified by:
countTotalin interfaceGroupService- Parameters:
context- The DSpace context- Returns:
- The total number of groups
- Throws:
SQLException- database exception
-
findByMetadataField
public List<Group> findByMetadataField(Context context, String searchValue, MetadataField metadataField) throws SQLException
Description copied from interface:GroupServiceLook up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)- Specified by:
findByMetadataFieldin interfaceGroupService- Parameters:
context- The DSpace contextsearchValue- The value to matchmetadataField- The metadata field to search in- Returns:
- The groups that have a matching value for specified metadata field
- Throws:
SQLException- database exception
-
-