Class XWikiGroupServiceImpl

  • All Implemented Interfaces:
    XWikiGroupService, org.xwiki.observation.EventListener

    public class XWikiGroupServiceImpl
    extends Object
    implements XWikiGroupService, org.xwiki.observation.EventListener
    Default implementation of XWikiGroupService users and groups manager.
    Version:
    $Id: 61853acf8e11d95f8cb5b36393dc084d62c91963 $
    • Field Detail

      • GROUPCLASS_REFERENCE

        public static final EntityReference GROUPCLASS_REFERENCE
    • Constructor Detail

      • XWikiGroupServiceImpl

        public XWikiGroupServiceImpl()
    • Method Detail

      • isAllGroupImplicit

        protected boolean isAllGroupImplicit​(XWikiContext context)
        Check whether the configuration specifies that every user is implicitly in XWikiAllGroup. Configured by the xwiki.authentication.group.allgroupimplicit parameter in xwiki.cfg.
        Parameters:
        context - the current XWiki context
        Returns:
        true if the group is implicit and all users should be by default in it, false if the group behaves as all other groups, containing only the users/subgroups that are explicitly listed inside the document.
      • replaceMemberInAllGroups

        public void replaceMemberInAllGroups​(DocumentReference memberSourceReference,
                                             DocumentReference memberTargetReference,
                                             XWikiContext context)
                                      throws XWikiException
        Description copied from interface: XWikiGroupService
        Replace a given member reference by another one in all groups of the wiki.
        Specified by:
        replaceMemberInAllGroups in interface XWikiGroupService
        Parameters:
        memberSourceReference - the reference of the member that should be replaced
        memberTargetReference - the reference of the member that is used as replacement
        context - the current context
        Throws:
        XWikiException - in case of problem when doing the replacement
      • getName

        public String getName()
        Specified by:
        getName in interface org.xwiki.observation.EventListener
      • getEvents

        public List<Event> getEvents()
        Specified by:
        getEvents in interface org.xwiki.observation.EventListener
      • onEvent

        public void onEvent​(Event event,
                            Object source,
                            Object data)
        Specified by:
        onEvent in interface org.xwiki.observation.EventListener
      • getAllMatchedUsers

        public List<?> getAllMatchedUsers​(Object[][] matchFields,
                                          boolean withdetails,
                                          int nb,
                                          int start,
                                          Object[][] order,
                                          XWikiContext context)
                                   throws XWikiException
        Description copied from interface: XWikiGroupService
        Search for all users with provided constraints and in a provided order.
        Specified by:
        getAllMatchedUsers in interface XWikiGroupService
        Parameters:
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        withdetails - indicate if a List containing String names is returned or List containing XWikiDocument.
        nb - the maximum number of results to return. Infinite if 0.
        start - the index of the first found user to return.
        order - the fields to order from. It is a table of table with :
        • fieldname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • asc : a Boolean, if true the order is ascendent
        context - the XWikiContext.
        Returns:
        the list of users.
        Throws:
        XWikiException - error when getting users.
      • getAllMatchedGroups

        public List<?> getAllMatchedGroups​(Object[][] matchFields,
                                           boolean withdetails,
                                           int nb,
                                           int start,
                                           Object[][] order,
                                           XWikiContext context)
                                    throws XWikiException
        Description copied from interface: XWikiGroupService
        Search for all groups with provided constraints and in a provided order.
        Specified by:
        getAllMatchedGroups in interface XWikiGroupService
        Parameters:
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        .
        withdetails - indicate if a List containing String names is returned or List containing XWikiDocument.
        nb - the maximum number of result to return. Infinite if 0.
        start - the index of the first found group to return.
        order - the field to order from. It is a table of table with :
        • fieldname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • asc : a Boolean, if true the order is ascendent
        context - the XWikiContext.
        Returns:
        the list of groups.
        Throws:
        XWikiException - error when getting groups.
      • createMatchUserOrGroupWhereClause

        protected String createMatchUserOrGroupWhereClause​(boolean user,
                                                           Object[][] matchFields,
                                                           Object[][] order,
                                                           List<Object> parameterValues)
        Create a "where clause" to use with XWikiStoreInterface searchDocuments and searchDocumentsNames methods.
        Parameters:
        user - if true search for users, otherwise search for groups.
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        order - the field to order from. It is a table of table with :
        • fieldname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • asc : a Boolean, if true the order is ascendent
        parameterValues - the list of values to fill for use with HQL named request.
        Returns:
        the formated HQL named request.
      • getAllMatchedUsersOrGroups

        protected List<?> getAllMatchedUsersOrGroups​(boolean user,
                                                     Object[][] matchFields,
                                                     boolean withdetails,
                                                     int nb,
                                                     int start,
                                                     Object[][] order,
                                                     XWikiContext context)
                                              throws XWikiException
        Search for all users or group with provided constraints and in a provided order.
        Parameters:
        user - if true search for users, otherwise search for groups.
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        withdetails - indicate if a List containing String names is returned or List containing XWikiDocument.
        nb - the maximum number of results to return. Infinite if 0.
        start - the index of the first found user or group to return.
        order - the field to order from. It is a table of table with :
        • fieldname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        context - the XWikiContext.
        Returns:
        the list of users or groups.
        Throws:
        XWikiException - error when calling for XWikiStoreInterface.searchDocuments(String, int, int, List, XWikiContext) or XWikiStoreInterface.searchDocumentsNames(String, int, int, List, XWikiContext)
      • countAllMatchedUsersOrGroups

        protected int countAllMatchedUsersOrGroups​(boolean user,
                                                   Object[][] matchFields,
                                                   XWikiContext context)
                                            throws XWikiException
        Return number of users or groups with provided constraints.
        Parameters:
        user - if true search for users, otherwise search for groups.
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        context - the XWikiContext.
        Returns:
        the of found users or groups.
        Throws:
        XWikiException - error when calling for XWikiStoreInterface.search(String, int, int, List, XWikiContext)
      • countAllMatchedUsers

        public int countAllMatchedUsers​(Object[][] matchFields,
                                        XWikiContext context)
                                 throws XWikiException
        Description copied from interface: XWikiGroupService
        Return number of users with provided constraints.
        Specified by:
        countAllMatchedUsers in interface XWikiGroupService
        Parameters:
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        .
        context - the XWikiContext.
        Returns:
        the of found users.
        Throws:
        XWikiException - error when getting number of users.
      • countAllMatchedGroups

        public int countAllMatchedGroups​(Object[][] matchFields,
                                         XWikiContext context)
                                  throws XWikiException
        Description copied from interface: XWikiGroupService
        Return number of groups with provided constraints.
        Specified by:
        countAllMatchedGroups in interface XWikiGroupService
        Parameters:
        matchFields - the field to math with values. It is a table of table with :
        • fiedname : the name of the field
        • fieldtype : for example StringProperty. If null the field is considered as document field
        • pattern matching : based on HQL "like" command
        .
        context - the XWikiContext.
        Returns:
        the of found groups.
        Throws:
        XWikiException - error when getting number of groups.
      • createMatchGroupMembersWhereClause

        protected String createMatchGroupMembersWhereClause​(String groupFullName,
                                                            String matchField,
                                                            Boolean orderAsc,
                                                            Map<String,​Object> parameterValues)
        Create a query to filter provided group members. Generate the entire HQL query except the select part.
        Parameters:
        groupFullName - the fill wiki name of the group.
        matchField - a string to search in result to filter.
        orderAsc - if true, the result is ordered ascendent, if false it descendant. If null no order is applied.
        parameterValues - the values to insert in names query.
        Returns:
        the HQL query.
        Since:
        1.6M1
      • getAllGroupsNamesForMember

        public Collection<String> getAllGroupsNamesForMember​(String member,
                                                             int nb,
                                                             int start,
                                                             XWikiContext context)
                                                      throws XWikiException
        Description copied from interface: XWikiGroupService
        Get all groups containing provided member in the provided member wiki.

        Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.

        Specified by:
        getAllGroupsNamesForMember in interface XWikiGroupService
        Parameters:
        member - the name of the member (user or group).
        nb - the maximum number of result to return.
        start - the index of the first found member to return.
        context - the XWiki context.
        Returns:
        the Collection of String containing group name.
        Throws:
        XWikiException - error when browsing groups.
      • getAllMembersNamesForGroup

        public Collection<String> getAllMembersNamesForGroup​(String group,
                                                             int nb,
                                                             int start,
                                                             XWikiContext context)
                                                      throws XWikiException
        Description copied from interface: XWikiGroupService
        Get all members provided group contains.

        Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.

        Specified by:
        getAllMembersNamesForGroup in interface XWikiGroupService
        Parameters:
        group - the name of the group.
        nb - the maximum number of result to return.
        start - the index of the first found user to return.
        context - the XWiki context.
        Returns:
        the Collection of String containing member name.
        Throws:
        XWikiException - error when browsing groups.
      • getAllMatchedMembersNamesForGroup

        public Collection<String> getAllMatchedMembersNamesForGroup​(String group,
                                                                    String matchField,
                                                                    int nb,
                                                                    int start,
                                                                    Boolean orderAsc,
                                                                    XWikiContext context)
                                                             throws XWikiException
        Description copied from interface: XWikiGroupService
        Get members of provided group.
        Specified by:
        getAllMatchedMembersNamesForGroup in interface XWikiGroupService
        Parameters:
        group - the group.
        matchField - a string to search in result to filter.
        nb - the maximum number of result to return.
        start - the index of the first found user to return.
        orderAsc - if true, the result is ordered ascendent, if false it descendant. If null no order is applied.
        context - the XWiki context.
        Returns:
        the Collection of String containing member name.
        Throws:
        XWikiException - error when browsing groups.
      • countAllGroupsNamesForMember

        public int countAllGroupsNamesForMember​(String member,
                                                XWikiContext context)
                                         throws XWikiException
        Description copied from interface: XWikiGroupService
        Return the number of groups containing provided member.

        Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.

        Specified by:
        countAllGroupsNamesForMember in interface XWikiGroupService
        Parameters:
        member - the name of the member (user or group).
        context - the XWiki context.
        Returns:
        the number of groups.
        Throws:
        XWikiException - error when getting number of users.
      • countAllMembersNamesForGroup

        public int countAllMembersNamesForGroup​(String group,
                                                XWikiContext context)
                                         throws XWikiException
        Description copied from interface: XWikiGroupService
        Return the number of members provided group contains.

        Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.

        Specified by:
        countAllMembersNamesForGroup in interface XWikiGroupService
        Parameters:
        group - the name of the group.
        context - the XWiki context.
        Returns:
        the number of members.
        Throws:
        XWikiException - error when getting number of groups.