1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.user.api

File XWikiGroupService.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
86% of files have more coverage

Code metrics

0
1
1
1
299
48
1
1
1
1
1

Classes

Class Line # Actions
XWikiGroupService 36 1 0% 1 2
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.user.api;
21   
22    import java.util.Collection;
23    import java.util.List;
24   
25    import org.xwiki.model.reference.DocumentReference;
26   
27    import com.xpn.xwiki.XWiki;
28    import com.xpn.xwiki.XWikiContext;
29    import com.xpn.xwiki.XWikiException;
30   
31    /**
32    * Interface giving access to users and groups management.
33    *
34    * @version $Id: 011bdde5b0228ed51e858bf98718aad3a8f94ee0 $
35    */
 
36    public interface XWikiGroupService
37    {
38    void init(XWiki xwiki, XWikiContext context) throws XWikiException;
39   
40    /**
41    * @deprecated since 10.8RC1, use GroupManager component instead
42    */
43    @Deprecated
44    void initCache(XWikiContext context) throws XWikiException;
45   
46    /**
47    * @deprecated since 10.8RC1, use GroupManager component instead
48    */
49    @Deprecated
50    void initCache(int iCapacity, XWikiContext context) throws XWikiException;
51   
52    /**
53    * @deprecated since 10.8RC1, use GroupManager component instead
54    */
55    @Deprecated
56    void flushCache();
57   
58    /**
59    * @deprecated Use {@link #getAllGroupsNamesForMember(String, int, int, XWikiContext)}.
60    */
61    @Deprecated
62    Collection<String> listGroupsForUser(String username, XWikiContext context) throws XWikiException;
63   
64    /**
65    * @deprecated should never be used ! There is a listener taking care of that automatically.
66    */
67    @Deprecated
68    void addUserToGroup(String user, String database, String group, XWikiContext context) throws XWikiException;
69   
70    /**
71    * Remove user or group name from all groups.
72    *
73    * @param userOrGroupWiki the name of the wiki of the member.
74    * @param userOrGroupSpace the name of the space of the member.
75    * @param userOrGroupName the name of the member.
76    * @param context the XWiki context.
77    * @throws XWikiException error when browsing groups.
78    * @since 1.1.2
79    * @since 1.2M2
80    */
81    void removeUserOrGroupFromAllGroups(String userOrGroupWiki, String userOrGroupSpace, String userOrGroupName,
82    XWikiContext context) throws XWikiException;
83   
84    /**
85    * @deprecated Use {@link #getAllMembersNamesForGroup(String, int, int, XWikiContext)}.
86    */
87    @Deprecated
88    List<String> listMemberForGroup(String s, XWikiContext context) throws XWikiException;
89   
90    /**
91    * @deprecated Use {@link #getAllMatchedGroups(Object[][], boolean, int, int, Object[][], XWikiContext)}.
92    */
93    @Deprecated
94    List<String> listAllGroups(XWikiContext context) throws XWikiException;
95   
96    /**
97    * Search for all users with provided constraints and in a provided order.
98    *
99    * @param matchFields the field to math with values. It is a table of table with :
100    * <ul>
101    * <li>fiedname : the name of the field</li>
102    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
103    * <li>pattern matching : based on HQL "like" command</li>
104    * </ul>
105    * @param withdetails indicate if a {@link List} containing {@link String} names is returned or {@link List}
106    * containing {@link com.xpn.xwiki.doc.XWikiDocument}.
107    * @param nb the maximum number of results to return. Infinite if 0.
108    * @param start the index of the first found user to return.
109    * @param order the fields to order from. It is a table of table with :
110    * <ul>
111    * <li>fieldname : the name of the field</li>
112    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
113    * <li>asc : a Boolean, if true the order is ascendent</li>
114    * </ul>
115    * @param context the {@link XWikiContext}.
116    * @return the list of users.
117    * @throws XWikiException error when getting users.
118    * @since 1.1.2
119    * @since 1.2M2
120    */
121    List<?> getAllMatchedUsers(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
122    XWikiContext context) throws XWikiException;
123   
124    /**
125    * Search for all groups with provided constraints and in a provided order.
126    *
127    * @param matchFields the field to math with values. It is a table of table with :
128    * <ul>
129    * <li>fiedname : the name of the field</li>
130    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
131    * <li>pattern matching : based on HQL "like" command</li>
132    * </ul>
133    * .
134    * @param withdetails indicate if a {@link List} containing {@link String} names is returned or {@link List}
135    * containing {@link com.xpn.xwiki.doc.XWikiDocument}.
136    * @param nb the maximum number of result to return. Infinite if 0.
137    * @param start the index of the first found group to return.
138    * @param order the field to order from. It is a table of table with :
139    * <ul>
140    * <li>fieldname : the name of the field</li>
141    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
142    * <li>asc : a Boolean, if true the order is ascendent</li>
143    * </ul>
144    * @param context the {@link XWikiContext}.
145    * @return the list of groups.
146    * @throws XWikiException error when getting groups.
147    * @since 1.1.2
148    * @since 1.2M2
149    */
150    List<?> getAllMatchedGroups(Object[][] matchFields, boolean withdetails, int nb, int start, Object[][] order,
151    XWikiContext context) throws XWikiException;
152   
153    /**
154    * Return number of users with provided constraints.
155    *
156    * @param matchFields the field to math with values. It is a table of table with :
157    * <ul>
158    * <li>fiedname : the name of the field</li>
159    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
160    * <li>pattern matching : based on HQL "like" command</li>
161    * </ul>
162    * .
163    * @param context the {@link XWikiContext}.
164    * @return the of found users.
165    * @throws XWikiException error when getting number of users.
166    * @since 1.1.2
167    * @since 1.2M2
168    */
169    int countAllMatchedUsers(Object[][] matchFields, XWikiContext context) throws XWikiException;
170   
171    /**
172    * Return number of groups with provided constraints.
173    *
174    * @param matchFields the field to math with values. It is a table of table with :
175    * <ul>
176    * <li>fiedname : the name of the field</li>
177    * <li>fieldtype : for example StringProperty. If null the field is considered as document field</li>
178    * <li>pattern matching : based on HQL "like" command</li>
179    * </ul>
180    * .
181    * @param context the {@link XWikiContext}.
182    * @return the of found groups.
183    * @throws XWikiException error when getting number of groups.
184    * @since 1.1.2
185    * @since 1.2M2
186    */
187    int countAllMatchedGroups(Object[][] matchFields, XWikiContext context) throws XWikiException;
188   
189    /**
190    * Get all groups containing provided member in the provided member wiki.
191    * <p>
192    * Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
193    *
194    * @param member the name of the member (user or group).
195    * @param nb the maximum number of result to return.
196    * @param start the index of the first found member to return.
197    * @param context the XWiki context.
198    * @return the {@link Collection} of {@link String} containing group name.
199    * @throws XWikiException error when browsing groups.
200    * @since 1.1.2
201    * @since 1.2M2
202    */
203    Collection<String> getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context)
204    throws XWikiException;
205   
206    /**
207    * Get all groups containing provided member in the current wiki.
208    * <p>
209    * Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
210    *
211    * @param memberReference the member. Can be either user or group.
212    * @param limit the maximum number of result to return.
213    * @param offset the index of the first found member to return.
214    * @param context the XWiki context.
215    * @return the {@link Collection} of {@link DocumentReference} containing representing groups.
216    * @throws XWikiException error when browsing groups.
217    * @since 2.4M2
218    */
219    Collection<DocumentReference> getAllGroupsReferencesForMember(DocumentReference memberReference, int limit,
220    int offset, XWikiContext context) throws XWikiException;
221   
222    /**
223    * Get all members provided group contains.
224    * <p>
225    * Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
226    *
227    * @param group the name of the group.
228    * @param nb the maximum number of result to return.
229    * @param start the index of the first found user to return.
230    * @param context the XWiki context.
231    * @return the {@link Collection} of {@link String} containing member name.
232    * @throws XWikiException error when browsing groups.
233    * @since 1.1.2
234    * @since 1.2M2
235    */
236    Collection<String> getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context)
237    throws XWikiException;
238   
239    /**
240    * Get members of provided group.
241    *
242    * @param group the group.
243    * @param matchField a string to search in result to filter.
244    * @param nb the maximum number of result to return.
245    * @param start the index of the first found user to return.
246    * @param orderAsc if true, the result is ordered ascendent, if false it descendant. If null no order is applied.
247    * @param context the XWiki context.
248    * @return the {@link Collection} of {@link String} containing member name.
249    * @throws XWikiException error when browsing groups.
250    * @since 1.6M1
251    */
252    Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start,
253    Boolean orderAsc, XWikiContext context) throws XWikiException;
254   
255    /**
256    * Filters the members of the specified group using the given text and counts the results.
257    *
258    * @param group the group whose members are going to be counted
259    * @param filter the text used to filter the group members
260    * @param xcontext the XWiki context
261    * @return the number of group members that match the given text filter
262    * @throws XWikiException if counting the group members fails
263    * @see #getAllMatchedMembersNamesForGroup(String, String, int, int, Boolean, XWikiContext)
264    * @since 10.8RC1
265    */
 
266  0 toggle default int countAllMatchedMembersNamesForGroup(String group, String filter, XWikiContext xcontext)
267    throws XWikiException
268    {
269  0 return getAllMatchedMembersNamesForGroup(group, filter, 0, 0, null, xcontext).size();
270    }
271   
272    /**
273    * Return the number of groups containing provided member.
274    * <p>
275    * Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
276    *
277    * @param member the name of the member (user or group).
278    * @param context the XWiki context.
279    * @return the number of groups.
280    * @throws XWikiException error when getting number of users.
281    * @since 1.1.2
282    * @since 1.2M2
283    */
284    int countAllGroupsNamesForMember(String member, XWikiContext context) throws XWikiException;
285   
286    /**
287    * Return the number of members provided group contains.
288    * <p>
289    * Since 10.8RC1 it's recommended to use org.xwiki.user.group.GroupManager unless you want to bypass the cache.
290    *
291    * @param group the name of the group.
292    * @param context the XWiki context.
293    * @return the number of members.
294    * @throws XWikiException error when getting number of groups.
295    * @since 1.1.2
296    * @since 1.2M2
297    */
298    int countAllMembersNamesForGroup(String group, XWikiContext context) throws XWikiException;
299    }