Class GroupServiceImpl

    • Field Detail

      • groupDAO

        @Autowired(required=true)
        protected GroupDAO groupDAO
      • group2GroupCacheDAO

        @Autowired(required=true)
        protected Group2GroupCacheDAO group2GroupCacheDAO
      • collectionService

        @Autowired(required=true)
        protected CollectionService collectionService
      • ePersonService

        @Autowired(required=true)
        protected EPersonService ePersonService
      • communityService

        @Autowired(required=true)
        protected CommunityService communityService
      • authorizeService

        @Autowired(required=true)
        protected AuthorizeService authorizeService
      • poolTaskService

        @Autowired(required=true)
        protected PoolTaskService poolTaskService
      • claimedTaskService

        @Autowired(required=true)
        protected ClaimedTaskService claimedTaskService
    • Constructor Detail

      • GroupServiceImpl

        protected GroupServiceImpl()
    • Method Detail

      • addMember

        public void addMember​(Context context,
                              Group group,
                              EPerson e)
        Description copied from interface: GroupService
        add an eperson member
        Specified by:
        addMember in interface GroupService
        Parameters:
        context - DSpace context object
        group - DSpace group
        e - eperson
      • addMember

        public void addMember​(Context context,
                              Group groupParent,
                              Group groupChild)
                       throws SQLException
        Description copied from interface: GroupService
        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
        Specified by:
        addMember in interface GroupService
        Parameters:
        context - DSpace context object
        groupParent - parent group
        groupChild - child group
        Throws:
        SQLException - if database error
      • removeMember

        public void removeMember​(Context context,
                                 Group group,
                                 EPerson ePerson)
                          throws SQLException
        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:
        removeMember in interface GroupService
        Parameters:
        context - DSpace context object
        group - DSpace group
        ePerson - eperson
        Throws:
        SQLException
      • removeMember

        public void removeMember​(Context context,
                                 Group groupParent,
                                 Group childGroup)
                          throws SQLException
        Description copied from interface: GroupService
        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
        Specified by:
        removeMember in interface GroupService
        Parameters:
        context - DSpace context object
        groupParent - parent group
        childGroup - child group
        Throws:
        SQLException - if database error
      • isDirectMember

        public boolean isDirectMember​(Group group,
                                      EPerson ePerson)
        Description copied from interface: GroupService
        check to see if an eperson is a direct member. If the eperson is a member via a subgroup will be returned false
        Specified by:
        isDirectMember in interface GroupService
        Parameters:
        group - DSpace group
        ePerson - eperson to check membership
        Returns:
        true or false
      • isMember

        public boolean isMember​(Group owningGroup,
                                Group childGroup)
        Description copied from interface: GroupService
        Check to see if childGroup is a direct group member of owningGroup. If childGroup is a subgroup via another group will be returned false
        Specified by:
        isMember in interface GroupService
        Parameters:
        owningGroup - parent group
        childGroup - child group
        Returns:
        true or false
      • isParentOf

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

        public boolean isMember​(Context context,
                                Group group)
                         throws SQLException
        Description copied from interface: GroupService
        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
        Specified by:
        isMember in interface GroupService
        Parameters:
        context - context
        group - 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: GroupService
        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.
        Specified by:
        isMember in interface GroupService
        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

        public boolean isMember​(Context context,
                                String groupName)
                         throws SQLException
        Description copied from interface: GroupService
        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.
        Specified by:
        isMember in interface GroupService
        Parameters:
        context - context
        groupName - 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: GroupService
        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.
        Specified by:
        isMember in interface GroupService
        Parameters:
        context - context
        eperson - 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
      • allMembers

        public List<EPerson> allMembers​(Context c,
                                        Group g)
                                 throws SQLException
        Description copied from interface: GroupService
        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.
        Specified by:
        allMembers in interface GroupService
        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: DSpaceObjectService
        Generic find for when the precise type of an Entity is not known
        Specified by:
        find in interface DSpaceObjectService<Group>
        Parameters:
        context - - the context
        id - - 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

        public Group findByName​(Context context,
                                String name)
                         throws SQLException
        Description copied from interface: GroupService
        Find the group by its name - assumes name is unique
        Specified by:
        findByName in interface GroupService
        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 use findAll(Context context, List<MetadataField> metadataSortFields) instead
        Specified by:
        findAll in interface GroupService
        Parameters:
        context - DSpace context
        sortField - 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,
                                   int pageSize,
                                   int offset)
                            throws SQLException
        Description copied from interface: GroupService
        Finds all groups in the site
        Specified by:
        findAll in interface GroupService
        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
      • search

        public List<Group> search​(Context context,
                                  String groupIdentifier)
                           throws SQLException
        Description copied from interface: GroupService
        Find the groups that match the search query across eperson_group_id or name
        Specified by:
        search in interface GroupService
        Parameters:
        context - DSpace context
        groupIdentifier - 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: GroupService
        Find the groups that match the search query across eperson_group_id or name
        Specified by:
        search in interface GroupService
        Parameters:
        context - DSpace context
        groupIdentifier - The group name or group ID
        offset - Inclusive offset
        limit - 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: GroupService
        Returns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.
        Specified by:
        searchResultCount in interface GroupService
        Parameters:
        context - DSpace context
        groupIdentifier - The search string
        Returns:
        the number of groups matching the query
        Throws:
        SQLException - if error
      • isEmpty

        public boolean isEmpty​(Group group)
        Return true if group has no direct or indirect members
        Specified by:
        isEmpty in interface GroupService
        Parameters:
        group - DSpace group
        Returns:
        true or false
      • getEmptyGroups

        public List<Group> getEmptyGroups​(Context context)
                                   throws SQLException
        Get a list of groups with no members.
        Specified by:
        getEmptyGroups in interface GroupService
        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.
      • 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: DSpaceObjectService
        Return 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:
        getParentObject in interface DSpaceObjectService<Group>
        Overrides:
        getParentObject in class DSpaceObjectServiceImpl<Group>
        Parameters:
        context - DSpace context
        group - DSpaceObject
        Returns:
        the dspace object that "own" the current object in the hierarchy
        Throws:
        SQLException - if database error
      • 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 relationships
        parent - the parent you're interested in
        Returns:
        Map whose keys are all of the children of a parent
      • countTotal

        public int countTotal​(Context context)
                       throws SQLException
        Description copied from interface: GroupService
        Count the total number of groups in DSpace
        Specified by:
        countTotal in interface GroupService
        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: GroupService
        Look up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)
        Specified by:
        findByMetadataField in interface GroupService
        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