1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.rightsmanager

File RightsManagerGroupsApi.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart1.png
82% of files have more coverage

Code metrics

0
112
50
1
1,007
349
62
0.55
2.24
50
1.24

Classes

Class Line # Actions
RightsManagerGroupsApi 45 112 0% 62 149
0.080246918%
 

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   
21    package com.xpn.xwiki.plugin.rightsmanager;
22   
23    import java.text.MessageFormat;
24    import java.util.Collections;
25    import java.util.List;
26    import java.util.Map;
27   
28    import org.slf4j.Logger;
29    import org.slf4j.LoggerFactory;
30   
31    import com.xpn.xwiki.XWikiContext;
32    import com.xpn.xwiki.XWikiException;
33    import com.xpn.xwiki.api.Api;
34    import com.xpn.xwiki.api.Document;
35    import com.xpn.xwiki.doc.XWikiDocument;
36    import com.xpn.xwiki.plugin.rightsmanager.utils.RequestLimit;
37   
38    /**
39    * API for managing groups.
40    *
41    * @version $Id: 85196f043c77762bed7e34435f41a003ccf1f1db $
42    * @since 1.1.2
43    * @since 1.2M2
44    */
 
45    public class RightsManagerGroupsApi extends Api
46    {
47    /**
48    * Field name of the last error code inserted in context.
49    */
50    public static final String CONTEXT_LASTERRORCODE = RightsManagerPluginApi.CONTEXT_LASTERRORCODE;
51   
52    /**
53    * Field name of the last api exception inserted in context.
54    */
55    public static final String CONTEXT_LASTEXCEPTION = RightsManagerPluginApi.CONTEXT_LASTEXCEPTION;
56   
57    /**
58    * The logging toolkit.
59    */
60    protected static final Logger LOGGER = LoggerFactory.getLogger(RightsManagerGroupsApi.class);
61   
62    /**
63    * Create an instance of RightsManageRightsApi.
64    *
65    * @param context the XWiki context.
66    */
 
67  22 toggle public RightsManagerGroupsApi(XWikiContext context)
68    {
69  22 super(context);
70    }
71   
72    /**
73    * Log error and register {@link #CONTEXT_LASTERRORCODE} and {@link #CONTEXT_LASTEXCEPTION}.
74    *
75    * @param comment the comment to use with {@link #LOGGER}.
76    * @param e the exception.
77    */
 
78  0 toggle private void logError(String comment, XWikiException e)
79    {
80  0 LOGGER.error(comment, e);
81   
82  0 this.context.put(CONTEXT_LASTERRORCODE, e.getCode());
83  0 this.context.put(CONTEXT_LASTEXCEPTION, e);
84    }
85   
86    // Count
87   
88    /**
89    * @return the number of groups in the current wiki.
90    * @throws XWikiException error when getting number of groups.
91    */
 
92  0 toggle public int countAllGroups() throws XWikiException
93    {
94  0 return countAllMatchedGroups(null);
95    }
96   
97    /**
98    * @param matchFields the fields to match. It is a Map with field name as key and for value :
99    * <ul>
100    * <li>"matching string" for document fields</li>
101    * <li>or ["field type", "matching string"] for object fields</li>
102    * </ul>
103    * @return the number of groups in the current wiki.
104    * @throws XWikiException error when getting number of groups.
105    */
 
106  0 toggle public int countAllMatchedGroups(Map<?, ?> matchFields) throws XWikiException
107    {
108  0 int count = 0;
109   
110  0 try {
111  0 count =
112    RightsManager.getInstance().countAllUsersOrGroups(false,
113    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
114    } catch (RightsManagerException e) {
115  0 logError("Try to count all groups", e);
116    }
117   
118  0 return count;
119    }
120   
121    /**
122    * Get the number of groups in the provided wiki.
123    *
124    * @param wikiName the name of the wiki where to search for groups.
125    * @return the number of groups in the provided wiki.
126    * @throws XWikiException error when getting number of groups.
127    */
 
128  0 toggle public int countAllWikiGroups(String wikiName) throws XWikiException
129    {
130  0 return countAllMatchedWikiGroups(wikiName, null);
131    }
132   
133    /**
134    * Get the number of groups in the provided wiki.
135    *
136    * @param wikiName the name of the wiki where to search for groups.
137    * @param matchFields the fields to match. It is a Map with field name as key and for value :
138    * <ul>
139    * <li>"matching string" for document fields</li>
140    * <li>or ["field type", "matching string"] for object fields</li>
141    * </ul>
142    * @return the number of groups in the provided wiki.
143    * @throws XWikiException error when getting number of groups.
144    */
 
145  0 toggle public int countAllMatchedWikiGroups(String wikiName, Map<?, ?> matchFields) throws XWikiException
146    {
147  0 int count = 0;
148   
149  0 try {
150  0 count =
151    RightsManager.getInstance().countAllWikiUsersOrGroups(false, wikiName,
152    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
153    } catch (RightsManagerException e) {
154  0 logError(MessageFormat.format("Try to count all groups in wiki [{0}]", new Object[] { wikiName }), e);
155    }
156   
157  0 return count;
158    }
159   
160    /**
161    * @return the number of groups in the main wiki.
162    * @throws XWikiException error when getting number of groups.
163    */
 
164  0 toggle public int countAllGlobalGroups() throws XWikiException
165    {
166  0 return countAllMatchedGlobalGroups(null);
167    }
168   
169    /**
170    * @param matchFields the fields to match. It is a Map with field name as key and for value :
171    * <ul>
172    * <li>"matching string" for document fields</li>
173    * <li>or ["field type", "matching string"] for object fields</li>
174    * </ul>
175    * @return the number of groups in the main wiki.
176    * @throws XWikiException error when getting number of groups.
177    */
 
178  0 toggle public int countAllMatchedGlobalGroups(Map<?, ?> matchFields) throws XWikiException
179    {
180  0 int count = 0;
181   
182  0 try {
183  0 count =
184    RightsManager.getInstance().countAllGlobalUsersOrGroups(false,
185    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
186    } catch (RightsManagerException e) {
187  0 logError("Try to count all groups in main wiki", e);
188    }
189   
190  0 return count;
191    }
192   
193    /**
194    * @return the number of groups in the current wiki.
195    * @throws XWikiException error when getting number of groups.
196    */
 
197  0 toggle public int countAllLocalGroups() throws XWikiException
198    {
199  0 return countAllMatchedLocalGroups(null);
200    }
201   
202    /**
203    * @param matchFields the fields to match. It is a Map with field name as key and for value :
204    * <ul>
205    * <li>"matching string" for document fields</li>
206    * <li>or ["field type", "matching string"] for object fields</li>
207    * </ul>
208    * @return the number of groups in the current wiki.
209    * @throws XWikiException error when getting number of groups.
210    */
 
211  4 toggle public int countAllMatchedLocalGroups(Map<?, ?> matchFields) throws XWikiException
212    {
213  4 int count = 0;
214   
215  4 try {
216  4 count =
217    RightsManager.getInstance().countAllLocalUsersOrGroups(false,
218    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
219    } catch (RightsManagerException e) {
220  0 logError("Try to count all groups in current wiki", e);
221    }
222   
223  4 return count;
224    }
225   
226    /**
227    * Get all groups names in the main wiki and the current wiki.
228    *
229    * @param nb the maximum number of result to return.
230    * @param start the index of the first found group to return.
231    * @return a {@link List} of {@link String} containing group names.
232    * @throws XWikiException error when searching for groups.
233    */
 
234  0 toggle public List<String> getAllGroupsNames(int nb, int start) throws XWikiException
235    {
236  0 return getAllMatchedGroupsNames(null, nb, start);
237    }
238   
239    /**
240    * Get all groups names in the main wiki and the current wiki.
241    *
242    * @return a {@link List} of {@link String} containing group names.
243    * @throws XWikiException error when searching for groups.
244    */
 
245  0 toggle public List<String> getAllGroupsNames() throws XWikiException
246    {
247  0 return getAllMatchedGroupsNames(null);
248    }
249   
250    /**
251    * Get all groups names in the main wiki and the current wiki.
252    *
253    * @param matchFields the fields to match. It is a Map with field name as key and for value :
254    * <ul>
255    * <li>"matching string" for document fields</li>
256    * <li>or ["field type", "matching string"] for object fields</li>
257    * </ul>
258    * @return a {@link List} of {@link String} containing group names.
259    * @throws XWikiException error when searching for groups.
260    */
 
261  0 toggle public List<String> getAllMatchedGroupsNames(Map<?, ?> matchFields) throws XWikiException
262    {
263  0 return getAllMatchedGroupsNames(matchFields, 0, 0, null);
264    }
265   
266    /**
267    * Get all groups names in the main wiki and the current wiki.
268    *
269    * @param matchFields the fields to match. It is a Map with field name as key and for value :
270    * <ul>
271    * <li>"matching string" for document fields</li>
272    * <li>or ["field type", "matching string"] for object fields</li>
273    * </ul>
274    * @param nb the maximum number of result to return.
275    * @param start the index of the first found group to return.
276    * @return a {@link List} of {@link String} containing group names.
277    * @throws XWikiException error when searching for groups.
278    */
 
279  0 toggle public List<String> getAllMatchedGroupsNames(Map<?, ?> matchFields, int nb, int start) throws XWikiException
280    {
281  0 return getAllMatchedGroupsNames(matchFields, nb, start, null);
282    }
283   
284    /**
285    * Get all groups names in the main wiki and the current wiki.
286    *
287    * @param matchFields the fields to match. It is a Map with field name as key and for value :
288    * <ul>
289    * <li>"matching string" for document fields</li>
290    * <li>or ["field type", "matching string"] for object fields</li>
291    * </ul>
292    * @param nb the maximum number of result to return.
293    * @param start the index of the first found group to return.
294    * @param order the fields to order from. It is a List containing :
295    * <ul>
296    * <li>"field name" for document fields</li>
297    * <li>or ["filed name", "field type"] for object fields</li>
298    * </ul>
299    * @return a {@link List} of {@link String} containing group names.
300    * @throws XWikiException error when searching for groups.
301    */
 
302  0 toggle public List<String> getAllMatchedGroupsNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
303    throws XWikiException
304    {
305  0 List<String> groupList;
306   
307  0 try {
308  0 groupList =
309    (List<String>) RightsManager.getInstance().getAllMatchedUsersOrGroups(false,
310    RightsManagerPluginApi.createMatchingTable(matchFields), false, new RequestLimit(nb, start),
311    RightsManagerPluginApi.createOrderTable(order), this.context);
312    } catch (RightsManagerException e) {
313  0 logError("Try to get all matched groups names", e);
314   
315  0 groupList = Collections.emptyList();
316    }
317   
318  0 return groupList;
319    }
320   
321    /**
322    * Get all groups names in the main wiki.
323    *
324    * @param nb the maximum number of result to return.
325    * @param start the index of the first found group to return.
326    * @return a {@link List} of {@link String} containing group names.
327    * @throws XWikiException error when searching for groups.
328    */
 
329  0 toggle public List<String> getAllGlobalGroupsNames(int nb, int start) throws XWikiException
330    {
331  0 return getAllMatchedGlobalGroupsNames(null, nb, start);
332    }
333   
334    /**
335    * Get all groups names in the main wiki.
336    *
337    * @return a {@link List} of {@link String} containing group names.
338    * @throws XWikiException error when searching for groups.
339    */
 
340  0 toggle public List<String> getAllGlobalGroupsNames() throws XWikiException
341    {
342  0 return getAllMatchedGlobalGroupsNames(null);
343    }
344   
345    /**
346    * Get all groups names in the main wiki.
347    *
348    * @param matchFields the fields to match. It is a Map with field name as key and for value :
349    * <ul>
350    * <li>"matching string" for document fields</li>
351    * <li>or ["field type", "matching string"] for object fields</li>
352    * </ul>
353    * @return a {@link List} of {@link String} containing group names.
354    * @throws XWikiException error when searching for groups.
355    */
 
356  0 toggle public List<String> getAllMatchedGlobalGroupsNames(Map<?, ?> matchFields) throws XWikiException
357    {
358  0 return getAllMatchedGlobalGroupsNames(matchFields, 0, 0, null);
359    }
360   
361    /**
362    * Get all groups names in the main wiki.
363    *
364    * @param matchFields the fields to match. It is a Map with field name as key and for value :
365    * <ul>
366    * <li>"matching string" for document fields</li>
367    * <li>or ["field type", "matching string"] for object fields</li>
368    * </ul>
369    * @param nb the maximum number of result to return.
370    * @param start the index of the first found group to return.
371    * @return a {@link List} of {@link String} containing group names.
372    * @throws XWikiException error when searching for groups.
373    */
 
374  0 toggle public List<String> getAllMatchedGlobalGroupsNames(Map<?, ?> matchFields, int nb, int start)
375    throws XWikiException
376    {
377  0 return getAllMatchedGlobalGroupsNames(matchFields, nb, start, null);
378    }
379   
380    /**
381    * Get all groups names in the main wiki.
382    *
383    * @param matchFields the fields to match. It is a Map with field name as key and for value :
384    * <ul>
385    * <li>"matching string" for document fields</li>
386    * <li>or ["field type", "matching string"] for object fields</li>
387    * </ul>
388    * @param nb the maximum number of result to return.
389    * @param start the index of the first found group to return.
390    * @param order the fields to order from. It is a List containing :
391    * <ul>
392    * <li>"field name" for document fields</li>
393    * <li>or ["filed name", "field type"] for object fields</li>
394    * </ul>
395    * @return a {@link List} of {@link String} containing group names.
396    * @throws XWikiException error when searching for groups.
397    */
 
398  0 toggle public List<String> getAllMatchedGlobalGroupsNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
399    throws XWikiException
400    {
401  0 List<String> groupList;
402   
403  0 try {
404  0 groupList =
405    (List<String>) RightsManager.getInstance().getAllMatchedGlobalUsersOrGroups(false,
406    RightsManagerPluginApi.createMatchingTable(matchFields), false, new RequestLimit(nb, start),
407    RightsManagerPluginApi.createOrderTable(order), this.context);
408    } catch (RightsManagerException e) {
409  0 logError("Try to get all matched groups names from global wiki", e);
410   
411  0 groupList = Collections.emptyList();
412    }
413   
414  0 return groupList;
415    }
416   
417    /**
418    * Get all groups names in the provided wiki.
419    *
420    * @param wikiName the name of the wiki where to search.
421    * @param nb the maximum number of result to return.
422    * @param start the index of the first found group to return.
423    * @return a {@link List} of {@link String} containing group names.
424    * @throws XWikiException error when searching for groups.
425    */
 
426  0 toggle public List<String> getAllWikiGroupsNames(String wikiName, int nb, int start) throws XWikiException
427    {
428  0 return getAllMatchedWikiGroupsNames(wikiName, null, nb, start);
429    }
430   
431    /**
432    * Get all groups names in the provided wiki.
433    *
434    * @param wikiName the name of the wiki where to search.
435    * @return a {@link List} of {@link String} containing group names.
436    * @throws XWikiException error when searching for groups.
437    */
 
438  0 toggle public List<String> getAllWikiGroupsNames(String wikiName) throws XWikiException
439    {
440  0 return getAllMatchedWikiGroupsNames(wikiName, null);
441    }
442   
443    /**
444    * Get all groups names in the provided wiki.
445    *
446    * @param wikiName the name of the wiki where to search.
447    * @param matchFields the fields to match. It is a Map with field name as key and for value :
448    * <ul>
449    * <li>"matching string" for document fields</li>
450    * <li>or ["field type", "matching string"] for object fields</li>
451    * </ul>
452    * @return a {@link List} of {@link String} containing group names.
453    * @throws XWikiException error when searching for groups.
454    */
 
455  0 toggle public List<String> getAllMatchedWikiGroupsNames(String wikiName, Map<?, ?> matchFields) throws XWikiException
456    {
457  0 return getAllMatchedWikiGroupsNames(wikiName, matchFields, 0, 0, null);
458    }
459   
460    /**
461    * Get all groups names in the provided wiki.
462    *
463    * @param wikiName the name of the wiki where to search.
464    * @param matchFields the fields to match. It is a Map with field name as key and for value :
465    * <ul>
466    * <li>"matching string" for document fields</li>
467    * <li>or ["field type", "matching string"] for object fields</li>
468    * </ul>
469    * @param nb the maximum number of result to return.
470    * @param start the index of the first found group to return.
471    * @return a {@link List} of {@link String} containing group names.
472    * @throws XWikiException error when searching for groups.
473    */
 
474  0 toggle public List<String> getAllMatchedWikiGroupsNames(String wikiName, Map<?, ?> matchFields, int nb, int start)
475    throws XWikiException
476    {
477  0 return getAllMatchedWikiGroupsNames(wikiName, matchFields, nb, start, null);
478    }
479   
480    /**
481    * Get all groups names in the provided wiki.
482    *
483    * @param wikiName the name of the wiki where to search.
484    * @param matchFields the fields to match. It is a Map with field name as key and for value :
485    * <ul>
486    * <li>"matching string" for document fields</li>
487    * <li>or ["field type", "matching string"] for object fields</li>
488    * </ul>
489    * @param nb the maximum number of result to return.
490    * @param start the index of the first found group to return.
491    * @param order the fields to order from. It is a List containing :
492    * <ul>
493    * <li>"field name" for document fields</li>
494    * <li>or ["filed name", "field type"] for object fields</li>
495    * </ul>
496    * @return a {@link List} of {@link String} containing group names.
497    * @throws XWikiException error when searching for groups.
498    */
 
499  0 toggle public List<String> getAllMatchedWikiGroupsNames(String wikiName, Map<?, ?> matchFields, int nb, int start,
500    List<?> order) throws XWikiException
501    {
502  0 List<String> groupList;
503   
504  0 try {
505  0 groupList =
506    (List<String>) RightsManager.getInstance().getAllMatchedWikiUsersOrGroups(false, wikiName,
507    RightsManagerPluginApi.createMatchingTable(matchFields), false, new RequestLimit(nb, start),
508    RightsManagerPluginApi.createOrderTable(order), this.context);
509    } catch (RightsManagerException e) {
510  0 logError("Try to get all matched groups names from provided wiki", e);
511   
512  0 groupList = Collections.emptyList();
513    }
514   
515  0 return groupList;
516    }
517   
518    /**
519    * Get all groups names in the current wiki.
520    *
521    * @param nb the maximum number of result to return.
522    * @param start the index of the first found group to return.
523    * @return a {@link List} of {@link String} containing group names.
524    * @throws XWikiException error when searching for groups.
525    */
 
526  0 toggle public List<String> getAllLocalGroupsNames(int nb, int start) throws XWikiException
527    {
528  0 return getAllMatchedLocalGroupsNames(null, nb, start);
529    }
530   
531    /**
532    * Get all groups names in the current wiki.
533    *
534    * @return a {@link List} of {@link String} containing group names.
535    * @throws XWikiException error when searching for groups.
536    */
 
537  0 toggle public List<String> getAllLocalGroupsNames() throws XWikiException
538    {
539  0 return getAllMatchedLocalGroupsNames(null);
540    }
541   
542    /**
543    * Get all groups names in the current wiki.
544    *
545    * @param matchFields the fields to match. It is a Map with field name as key and for value :
546    * <ul>
547    * <li>"matching string" for document fields</li>
548    * <li>or ["field type", "matching string"] for object fields</li>
549    * </ul>
550    * @return a {@link List} of {@link String} containing group names.
551    * @throws XWikiException error when searching for groups.
552    */
 
553  0 toggle public List<String> getAllMatchedLocalGroupsNames(Map<?, ?> matchFields) throws XWikiException
554    {
555  0 return getAllMatchedLocalGroupsNames(matchFields, 0, 0, null);
556    }
557   
558    /**
559    * Get all groups names in the current wiki.
560    *
561    * @param matchFields the fields to match. It is a Map with field name as key and for value :
562    * <ul>
563    * <li>"matching string" for document fields</li>
564    * <li>or ["field type", "matching string"] for object fields</li>
565    * </ul>
566    * @param nb the maximum number of result to return.
567    * @param start the index of the first found group to return.
568    * @return a {@link List} of {@link String} containing group names.
569    * @throws XWikiException error when searching for groups.
570    */
 
571  0 toggle public List<String> getAllMatchedLocalGroupsNames(Map<?, ?> matchFields, int nb, int start)
572    throws XWikiException
573    {
574  0 return getAllMatchedLocalGroupsNames(matchFields, nb, start, null);
575    }
576   
577    /**
578    * Get all groups names in the current wiki.
579    *
580    * @param matchFields the fields to match. It is a Map with field name as key and for value :
581    * <ul>
582    * <li>"matching string" for document fields</li>
583    * <li>or ["field type", "matching string"] for object fields</li>
584    * </ul>
585    * @param nb the maximum number of result to return.
586    * @param start the index of the first found group to return.
587    * @param order the fields to order from. It is a List containing :
588    * <ul>
589    * <li>"field name" for document fields</li>
590    * <li>or ["filed name", "field type"] for object fields</li>
591    * </ul>
592    * @return a {@link List} of {@link String} containing group names.
593    * @throws XWikiException error when searching for groups.
594    */
 
595  0 toggle public List<String> getAllMatchedLocalGroupsNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
596    throws XWikiException
597    {
598  0 List<String> groupList;
599   
600  0 try {
601  0 groupList =
602    (List<String>) RightsManager.getInstance().getAllMatchedLocalUsersOrGroups(false,
603    RightsManagerPluginApi.createMatchingTable(matchFields), false, new RequestLimit(nb, start),
604    RightsManagerPluginApi.createOrderTable(order), this.context);
605    } catch (RightsManagerException e) {
606  0 logError("Try to get all matched groups names from local wiki", e);
607   
608  0 groupList = Collections.emptyList();
609    }
610   
611  0 return groupList;
612    }
613   
614    /**
615    * Get all groups in the main wiki and the current wiki.
616    *
617    * @param nb the maximum number of result to return.
618    * @param start the index of the first found group to return.
619    * @return a {@link List} of {@link Document} containing group.
620    * @throws XWikiException error when searching for groups.
621    */
 
622  0 toggle public List<Document> getAllGroups(int nb, int start) throws XWikiException
623    {
624  0 return getAllMatchedGroups(null, nb, start);
625    }
626   
627    /**
628    * Get all groups in the main wiki and the current wiki.
629    *
630    * @return a {@link List} of {@link Document} containing group.
631    * @throws XWikiException error when searching for groups.
632    */
 
633  0 toggle public List<Document> getAllGroups() throws XWikiException
634    {
635  0 return getAllMatchedGroups(null);
636    }
637   
638    /**
639    * Get all groups in the main wiki and the current wiki.
640    *
641    * @param matchFields the fields to match. It is a Map with field name as key and for value :
642    * <ul>
643    * <li>"matching string" for document fields</li>
644    * <li>or ["field type", "matching string"] for object fields</li>
645    * </ul>
646    * @return a {@link List} of {@link Document} containing group.
647    * @throws XWikiException error when searching for groups.
648    */
 
649  0 toggle public List<Document> getAllMatchedGroups(Map<?, ?> matchFields) throws XWikiException
650    {
651  0 return getAllMatchedGroups(matchFields, 0, 0, null);
652    }
653   
654    /**
655    * Get all groups in the main wiki and the current wiki.
656    *
657    * @param matchFields the fields to match. It is a Map with field name as key and for value :
658    * <ul>
659    * <li>"matching string" for document fields</li>
660    * <li>or ["field type", "matching string"] for object fields</li>
661    * </ul>
662    * @param nb the maximum number of result to return.
663    * @param start the index of the first found group to return.
664    * @return a {@link List} of {@link Document} containing group.
665    * @throws XWikiException error when searching for groups.
666    */
 
667  0 toggle public List<Document> getAllMatchedGroups(Map<?, ?> matchFields, int nb, int start) throws XWikiException
668    {
669  0 return getAllMatchedGroups(matchFields, nb, start, null);
670    }
671   
672    /**
673    * Get all groups in the main wiki and the current wiki.
674    *
675    * @param matchFields the fields to match. It is a Map with field name as key and for value :
676    * <ul>
677    * <li>"matching string" for document fields</li>
678    * <li>or ["field type", "matching string"] for object fields</li>
679    * </ul>
680    * @param nb the maximum number of result to return.
681    * @param start the index of the first found group to return.
682    * @param order the fields to order from. It is a List containing :
683    * <ul>
684    * <li>"field name" for document fields</li>
685    * <li>or ["filed name", "field type"] for object fields</li>
686    * </ul>
687    * @return a {@link List} of {@link Document} containing group.
688    * @throws XWikiException error when searching for groups.
689    */
 
690  0 toggle public List<Document> getAllMatchedGroups(Map<?, ?> matchFields, int nb, int start, List<?> order)
691    throws XWikiException
692    {
693  0 List<Document> groupList;
694   
695  0 try {
696  0 List<XWikiDocument> xdocList =
697    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedUsersOrGroups(false,
698    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
699    RightsManagerPluginApi.createOrderTable(order), this.context);
700   
701  0 groupList = convert(xdocList);
702    } catch (RightsManagerException e) {
703  0 logError("Try to get all matched groups documents", e);
704   
705  0 groupList = Collections.emptyList();
706    }
707   
708  0 return groupList;
709    }
710   
711    /**
712    * Get all groups in the main wiki.
713    *
714    * @param nb the maximum number of result to return.
715    * @param start the index of the first found group to return.
716    * @return a {@link List} of {@link Document} containing group.
717    * @throws XWikiException error when searching for groups.
718    */
 
719  0 toggle public List<Document> getAllGlobalGroups(int nb, int start) throws XWikiException
720    {
721  0 return getAllMatchedGlobalGroups(null, nb, start);
722    }
723   
724    /**
725    * Get all groups in the main wiki.
726    *
727    * @return a {@link List} of {@link Document} containing group.
728    * @throws XWikiException error when searching for groups.
729    */
 
730  0 toggle public List<Document> getAllGlobalGroups() throws XWikiException
731    {
732  0 return getAllMatchedGlobalGroups(null);
733    }
734   
735    /**
736    * Get all groups in the main wiki.
737    *
738    * @param matchFields the fields to match. It is a Map with field name as key and for value :
739    * <ul>
740    * <li>"matching string" for document fields</li>
741    * <li>or ["field type", "matching string"] for object fields</li>
742    * </ul>
743    * @return a {@link List} of {@link Document} containing group.
744    * @throws XWikiException error when searching for groups.
745    */
 
746  0 toggle public List<Document> getAllMatchedGlobalGroups(Map<?, ?> matchFields) throws XWikiException
747    {
748  0 return getAllMatchedGlobalGroups(matchFields, 0, 0, null);
749    }
750   
751    /**
752    * Get all groups in the main wiki.
753    *
754    * @param matchFields the fields to match. It is a Map with field name as key and for value :
755    * <ul>
756    * <li>"matching string" for document fields</li>
757    * <li>or ["field type", "matching string"] for object fields</li>
758    * </ul>
759    * @param nb the maximum number of result to return.
760    * @param start the index of the first found group to return.
761    * @return a {@link List} of {@link Document} containing group.
762    * @throws XWikiException error when searching for groups.
763    */
 
764  0 toggle public List<Document> getAllMatchedGlobalGroups(Map<?, ?> matchFields, int nb, int start) throws XWikiException
765    {
766  0 return getAllMatchedGlobalGroups(matchFields, nb, start, null);
767    }
768   
769    /**
770    * Get all groups in the main wiki.
771    *
772    * @param matchFields the fields to match. It is a Map with field name as key and for value :
773    * <ul>
774    * <li>"matching string" for document fields</li>
775    * <li>or ["field type", "matching string"] for object fields</li>
776    * </ul>
777    * @param nb the maximum number of result to return.
778    * @param start the index of the first found group to return.
779    * @param order the fields to order from. It is a List containing :
780    * <ul>
781    * <li>"field name" for document fields</li>
782    * <li>or ["filed name", "field type"] for object fields</li>
783    * </ul>
784    * @return a {@link List} of {@link Document} containing group.
785    * @throws XWikiException error when searching for groups.
786    */
 
787  0 toggle public List<Document> getAllMatchedGlobalGroups(Map<?, ?> matchFields, int nb, int start, List<?> order)
788    throws XWikiException
789    {
790  0 List<Document> groupList;
791   
792  0 try {
793  0 List<XWikiDocument> xdocList =
794    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedGlobalUsersOrGroups(false,
795    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
796    RightsManagerPluginApi.createOrderTable(order), this.context);
797   
798  0 groupList = convert(xdocList);
799    } catch (RightsManagerException e) {
800  0 logError("Try to get all matched groups documents from global wiki", e);
801   
802  0 groupList = Collections.emptyList();
803    }
804   
805  0 return groupList;
806    }
807   
808    /**
809    * Get all groups in the provided wiki.
810    *
811    * @param wikiName the name of the wiki where to search.
812    * @param nb the maximum number of result to return.
813    * @param start the index of the first found group to return.
814    * @return a {@link List} of {@link Document} containing group.
815    * @throws XWikiException error when searching for groups.
816    */
 
817  0 toggle public List<Document> getAllWikiGroups(String wikiName, int nb, int start) throws XWikiException
818    {
819  0 return getAllMatchedWikiGroups(wikiName, null, nb, start);
820    }
821   
822    /**
823    * Get all groups in the provided wiki.
824    *
825    * @param wikiName the name of the wiki where to search.
826    * @return a {@link List} of {@link Document} containing group.
827    * @throws XWikiException error when searching for groups.
828    */
 
829  0 toggle public List<Document> getAllWikiGroups(String wikiName) throws XWikiException
830    {
831  0 return getAllMatchedWikiGroups(wikiName, null);
832    }
833   
834    /**
835    * Get all groups in the provided wiki.
836    *
837    * @param wikiName the name of the wiki where to search.
838    * @param matchFields the fields to match. It is a Map with field name as key and for value :
839    * <ul>
840    * <li>"matching string" for document fields</li>
841    * <li>or ["field type", "matching string"] for object fields</li>
842    * </ul>
843    * @return a {@link List} of {@link Document} containing group.
844    * @throws XWikiException error when searching for groups.
845    */
 
846  0 toggle public List<Document> getAllMatchedWikiGroups(String wikiName, Map<?, ?> matchFields) throws XWikiException
847    {
848  0 return getAllMatchedWikiGroups(wikiName, matchFields, 0, 0, null);
849    }
850   
851    /**
852    * Get all groups in the provided wiki.
853    *
854    * @param wikiName the name of the wiki where to search.
855    * @param matchFields the fields to match. It is a Map with field name as key and for value :
856    * <ul>
857    * <li>"matching string" for document fields</li>
858    * <li>or ["field type", "matching string"] for object fields</li>
859    * </ul>
860    * @param nb the maximum number of result to return.
861    * @param start the index of the first found group to return.
862    * @return a {@link List} of {@link Document} containing group.
863    * @throws XWikiException error when searching for groups.
864    */
 
865  0 toggle public List<Document> getAllMatchedWikiGroups(String wikiName, Map<?, ?> matchFields, int nb, int start)
866    throws XWikiException
867    {
868  0 return getAllMatchedWikiGroups(wikiName, matchFields, nb, start, null);
869    }
870   
871    /**
872    * Get all groups in the provided wiki.
873    *
874    * @param wikiName the name of the wiki where to search.
875    * @param matchFields the fields to match. It is a Map with field name as key and for value :
876    * <ul>
877    * <li>"matching string" for document fields</li>
878    * <li>or ["field type", "matching string"] for object fields</li>
879    * </ul>
880    * @param nb the maximum number of result to return.
881    * @param start the index of the first found group to return.
882    * @param order the fields to order from. It is a List containing :
883    * <ul>
884    * <li>"field name" for document fields</li>
885    * <li>or ["filed name", "field type"] for object fields</li>
886    * </ul>
887    * @return a {@link List} of {@link Document} containing group.
888    * @throws XWikiException error when searching for groups.
889    */
 
890  0 toggle public List<Document> getAllMatchedWikiGroups(String wikiName, Map<?, ?> matchFields, int nb, int start,
891    List<?> order) throws XWikiException
892    {
893  0 List<Document> groupList;
894   
895  0 try {
896  0 List<XWikiDocument> xdocList =
897    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedWikiUsersOrGroups(false, wikiName,
898    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
899    RightsManagerPluginApi.createOrderTable(order), this.context);
900   
901  0 groupList = convert(xdocList);
902    } catch (RightsManagerException e) {
903  0 logError("Try to get all matched groups documents from provided wiki", e);
904   
905  0 groupList = Collections.emptyList();
906    }
907   
908  0 return groupList;
909    }
910   
911    /**
912    * Get all groups in the current wiki.
913    *
914    * @param nb the maximum number of result to return.
915    * @param start the index of the first found group to return.
916    * @return a {@link List} of {@link Document} containing group.
917    * @throws XWikiException error when searching for groups.
918    */
 
919  0 toggle public List<Document> getAllLocalGroups(int nb, int start) throws XWikiException
920    {
921  0 return getAllMatchedLocalGroups(null, nb, start);
922    }
923   
924    /**
925    * Get all groups in the current wiki.
926    *
927    * @return a {@link List} of {@link Document} containing group.
928    * @throws XWikiException error when searching for groups.
929    */
 
930  0 toggle public List<Document> getAllLocalGroups() throws XWikiException
931    {
932  0 return getAllMatchedLocalGroups(null);
933    }
934   
935    /**
936    * Get all groups in the current wiki.
937    *
938    * @param matchFields the fields to match. It is a Map with field name as key and for value :
939    * <ul>
940    * <li>"matching string" for document fields</li>
941    * <li>or ["field type", "matching string"] for object fields</li>
942    * </ul>
943    * @return a {@link List} of {@link Document} containing group.
944    * @throws XWikiException error when searching for groups.
945    */
 
946  0 toggle public List<Document> getAllMatchedLocalGroups(Map<?, ?> matchFields) throws XWikiException
947    {
948  0 return getAllMatchedLocalGroups(matchFields, 0, 0, null);
949    }
950   
951    /**
952    * Get all groups in the current wiki.
953    *
954    * @param matchFields the fields to match. It is a Map with field name as key and for value :
955    * <ul>
956    * <li>"matching string" for document fields</li>
957    * <li>or ["field type", "matching string"] for object fields</li>
958    * </ul>
959    * @param nb the maximum number of result to return.
960    * @param start the index of the first found group to return.
961    * @return a {@link List} of {@link Document} containing group.
962    * @throws XWikiException error when searching for groups.
963    */
 
964  0 toggle public List<Document> getAllMatchedLocalGroups(Map<?, ?> matchFields, int nb, int start) throws XWikiException
965    {
966  0 return getAllMatchedLocalGroups(matchFields, nb, start, null);
967    }
968   
969    /**
970    * Get all groups in the current wiki.
971    *
972    * @param matchFields the fields to match. It is a Map with field name as key and for value :
973    * <ul>
974    * <li>"matching string" for document fields</li>
975    * <li>or ["field type", "matching string"] for object fields</li>
976    * </ul>
977    * @param nb the maximum number of result to return.
978    * @param start the index of the first found group to return.
979    * @param order the fields to order from. It is a List containing :
980    * <ul>
981    * <li>"field name" for document fields</li>
982    * <li>or ["filed name", "field type"] for object fields</li>
983    * </ul>
984    * @return a {@link List} of {@link Document} containing group.
985    * @throws XWikiException error when searching for groups.
986    */
 
987  4 toggle public List<Document> getAllMatchedLocalGroups(Map<?, ?> matchFields, int nb, int start, List<?> order)
988    throws XWikiException
989    {
990  4 List<Document> groupList;
991   
992  4 try {
993  4 List<XWikiDocument> xdocList =
994    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedLocalUsersOrGroups(false,
995    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
996    RightsManagerPluginApi.createOrderTable(order), this.context);
997   
998  4 groupList = convert(xdocList);
999    } catch (RightsManagerException e) {
1000  0 logError("Try to get all matched groups documents from local wiki", e);
1001   
1002  0 groupList = Collections.emptyList();
1003    }
1004   
1005  4 return groupList;
1006    }
1007    }