Package org.dspace.eperson
Class GroupServiceImpl
- All Implemented Interfaces:
DSpaceObjectLegacySupportService<Group>,DSpaceObjectService<Group>,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
FieldsModifier and TypeFieldDescriptionprotected AuthorizeServiceprotected ClaimedTaskServiceprotected CollectionRoleServiceprotected CollectionServiceprotected CommunityServiceprotected EPersonServiceprotected Group2GroupCacheDAOprotected GroupDAOprotected PoolTaskServiceprotected ResourcePolicyServiceprotected XmlWorkflowFactoryFields inherited from class org.dspace.content.DSpaceObjectServiceImpl
choiceAuthorityService, handleService, metadataAuthorityService, metadataFieldService, metadataValueService, relationshipServiceFields 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_DESCRIPTIONFields inherited from interface org.dspace.eperson.service.GroupService
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd an eperson membervoidadd group to this group.allMemberGroups(Context context, EPerson ePerson) Get all of the groups that an eperson is a member of.allMemberGroupsSet(Context context, EPerson ePerson) allMembers(Context c, Group g) 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.intcountAllMembers(Context context, Group group) 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.intcountByParent(Context context, Group parent) Return number of groups which are a member of the given Parent group.intcountTotal(Context context) Count the total number of groups in DSpaceCreate a new groupvoidGeneric find for when the precise type of an Entity is not knownDeprecated.findAll(Context context, List<MetadataField> metadataSortFields) findAll(Context context, List<MetadataField> metadataSortFields, int pageSize, int offset) Finds all groups in the sitefindByIdOrLegacyId(Context context, String id) findByLegacyId(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.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)findByName(Context context, String name) Find the group by its name - assumes name is uniquefindByParent(Context context, Group parent, int pageSize, int offset) Find all groups which are a member of the given Parent groupUsed recursively to generate a map of ALL of the children of the given parentgetEmptyGroups(Context context) Get a list of groups with no members.Get a proper name for the object.getParentObject(Context context, Group group) Return the dspace object that "own" the current object in the hierarchy.intReturns 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.booleanReturn true if group has no direct or indirect membersprotected booleanisEPersonInGroup(Context context, Group group, EPerson ePerson) booleanfast check to see if an eperson is a member called with eperson id.booleanfast check to see if an eperson is a member called with eperson id.booleanfast check to see if an eperson is a member called with eperson id.booleanfast check to see if an eperson is a member called with eperson id.booleanCheck 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) Removes a member of a group.voidremoveMember(Context context, Group groupParent, Group childGroup) remove group from this group.protected 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 groupFind the Groups that match the query across both Group name and Group ID.Find the Groups that match the query across both Group name and Group ID.searchNonMembers(Context context, String query, Group excludeParentGroup, int offset, int limit) Find the groups that match the search query which are NOT currently members (subgroups) of the given parentGroupintsearchNonMembersCount(Context context, String query, Group excludeParentGroup) Returns the total number of groups that match the search query which are NOT currently members (subgroups) of the given parentGroup.intsearchResultCount(Context context, String query) Returns the total number of Groups returned by a specific query.voidset name of groupvoidUpdate 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, addMetadata, addMetadata, clearMetadata, getAdminObject, getAuthoritiesAndConfidences, getElements, getElementsFilled, getIdentifiers, getMDValueByField, getMDValueByLegacyField, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getMetadataValuePlace, getTypeText, match, moveMetadata, moveSingleMetadataValue, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dspace.content.service.DSpaceObjectService
addAndShiftRightMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, addMetadata, clearMetadata, getAdminObject, getIdentifiers, getMetadata, getMetadata, getMetadata, getMetadata, getMetadataByMetadataString, getMetadataFirstValue, getMetadataFirstValue, getTypeText, moveMetadata, removeMetadataValues, replaceMetadata, setMetadataModified, setMetadataSingleValue, setMetadataSingleValue
-
Field Details
-
groupDAO
-
group2GroupCacheDAO
-
collectionService
-
collectionRoleService
-
ePersonService
-
communityService
-
authorizeService
-
resourcePolicyService
-
poolTaskService
-
claimedTaskService
-
workflowFactory
-
-
Constructor Details
-
GroupServiceImpl
protected GroupServiceImpl()
-
-
Method Details
-
create
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
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
Description copied from interface:GroupServiceadd an eperson member- Specified by:
addMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroup- DSpace groupe- eperson
-
addMember
Description copied from interface:GroupServiceadd 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- Specified by:
addMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroupParent- parent groupgroupChild- child group- Throws:
SQLException- if database error
-
removeMember
Removes a member of a group. The removal will be refused if the group is linked to a workflow step which has claimed tasks or pool tasks and no other member is present in the group to handle these.- Specified by:
removeMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroup- DSpace groupePerson- eperson- Throws:
SQLException
-
removeMember
Description copied from interface:GroupServiceremove 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- Specified by:
removeMemberin interfaceGroupService- Parameters:
context- DSpace context objectgroupParent- parent groupchildGroup- child group- Throws:
SQLException- if database error
-
isDirectMember
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
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
Description copied from interface:GroupServiceCheck to see if parentGroup is a direct or in-direct parent of a childGroup.- Specified by:
isParentOfin interfaceGroupService- Parameters:
context- current DSpace session.parentGroup- parent groupchildGroup- child group- Returns:
- true or false
- Throws:
SQLException
-
isMember
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 eperson 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
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 eperson objects and is thus a static method.- Specified by:
isMemberin interfaceGroupService- 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
-
isMember
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 eperson objects and is thus a static method. This method uses context.getCurrentUser() as eperson whose 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
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 eperson objects and is thus a static method. The eperson whose membership should be checked must be defined as method attribute.- Specified by:
isMemberin interfaceGroupService- Parameters:
context- contexteperson- 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
-
allMemberGroups
Description copied from interface:GroupServiceGet all of the groups that an eperson is a member of.- Specified by:
allMemberGroupsin interfaceGroupService- Parameters:
context- DSpace contextePerson- ePerson object- Returns:
- list of Group objects
- Throws:
SQLException- if database error
-
allMemberGroupsSet
- Specified by:
allMemberGroupsSetin interfaceGroupService- Throws:
SQLException
-
allMembers
Description copied from interface:GroupServiceGet 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.
- Specified by:
allMembersin interfaceGroupService- Parameters:
c- The relevant DSpace Context.g- Group object- Returns:
- List of EPerson objects
- Throws:
SQLException- if error
-
countAllMembers
Description copied from interface:GroupServiceCount 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.- Specified by:
countAllMembersin interfaceGroupService- Parameters:
context- current DSpace contextgroup- Group object- Returns:
- count of EPerson object members
- Throws:
SQLException- if error
-
find
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 typed dspace objects- Returns:
- the dspace object found, or null if it does not exist.
- Throws:
SQLException- only upon failure accessing the database.
-
findByName
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.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
Description copied from interface:GroupServiceFind 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.- Specified by:
searchin interfaceGroupService- Parameters:
context- DSpace contextquery- The search string used to search across group name or group ID- Returns:
- List of matching Group objects
- Throws:
SQLException- if error
-
search
Description copied from interface:GroupServiceFind 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.- Specified by:
searchin interfaceGroupService- Parameters:
context- DSpace contextquery- The search string used to search across group name or group IDoffset- 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
Description copied from interface:GroupServiceReturns 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.- Specified by:
searchResultCountin interfaceGroupService- Parameters:
context- DSpace contextquery- 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
public List<Group> searchNonMembers(Context context, String query, Group excludeParentGroup, int offset, int limit) throws SQLException Description copied from interface:GroupServiceFind the groups that match the search query which are NOT currently members (subgroups) of the given parentGroup- Specified by:
searchNonMembersin interfaceGroupService- Parameters:
context- DSpace contextquery- The search string used to search across group name or group IDexcludeParentGroup- Parent group to exclude results fromoffset- 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
public int searchNonMembersCount(Context context, String query, Group excludeParentGroup) throws SQLException Description copied from interface:GroupServiceReturns 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.- Specified by:
searchNonMembersCountin interfaceGroupService- Parameters:
context- DSpace contextquery- The search string used to search across group name or group IDexcludeParentGroup- Parent group to exclude results from- Returns:
- the number of Groups matching the query
- Throws:
SQLException- if error
-
delete
- 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
Return true if group has no direct or indirect members- Specified by:
isEmptyin interfaceGroupService- Parameters:
group- DSpace group- Returns:
- true or false
-
initDefaultGroupNames
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
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
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
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
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
- Specified by:
updateLastModifiedin interfaceDSpaceObjectService<Group>
-
getChildren
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
- Specified by:
findByIdOrLegacyIdin interfaceDSpaceObjectLegacySupportService<Group>- Throws:
SQLException
-
findByLegacyId
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
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
-
getName
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<Group>- Overrides:
getNamein classDSpaceObjectServiceImpl<Group>- Parameters:
dso- DSpaceObject- Returns:
- Name for the object, or
nullif it doesn't have one
-
findByParent
public List<Group> findByParent(Context context, Group parent, int pageSize, int offset) throws SQLException Description copied from interface:GroupServiceFind all groups which are a member of the given Parent group- Specified by:
findByParentin interfaceGroupService- Parameters:
context- The relevant DSpace Context.parent- The parent Group to search onpageSize- how many results returnoffset- 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
Description copied from interface:GroupServiceReturn 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.- Specified by:
countByParentin interfaceGroupService- 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
-