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

File RightsManagerUsersApi.java

 

Coverage histogram

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

Code metrics

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

Classes

Class Line # Actions
RightsManagerUsersApi 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 users.
40    *
41    * @version $Id: bed42a54ae09900e63f5f618f4784881f9999a01 $
42    * @since 1.1.2
43    * @since 1.2M2
44    */
 
45    public class RightsManagerUsersApi 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(RightsManagerUsersApi.class);
61   
62    /**
63    * Create an instance of RightsManageRightsApi.
64    *
65    * @param context the XWiki context.
66    */
 
67  22 toggle public RightsManagerUsersApi(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 users in the current wiki.
90    * @throws XWikiException error when getting number of users.
91    */
 
92  0 toggle public int countAllUsers() throws XWikiException
93    {
94  0 return countAllMatchedUsers(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 users in the current wiki.
104    * @throws XWikiException error when getting number of users.
105    */
 
106  0 toggle public int countAllMatchedUsers(Map<?, ?> matchFields) throws XWikiException
107    {
108  0 int count = 0;
109   
110  0 try {
111  0 count =
112    RightsManager.getInstance().countAllUsersOrGroups(true,
113    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
114    } catch (RightsManagerException e) {
115  0 logError("Try to count all users", e);
116    }
117   
118  0 return count;
119    }
120   
121    /**
122    * Get the number of users in the provided wiki.
123    *
124    * @param wikiName the name of the wiki where to search for users.
125    * @return the number of users in the provided wiki.
126    * @throws XWikiException error when getting number of users.
127    */
 
128  0 toggle public int countAllWikiUsers(String wikiName) throws XWikiException
129    {
130  0 return countAllMatchedWikiUsers(wikiName, null);
131    }
132   
133    /**
134    * Get the number of users in the provided wiki.
135    *
136    * @param wikiName the name of the wiki where to search for users.
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 users in the provided wiki.
143    * @throws XWikiException error when getting number of users.
144    */
 
145  0 toggle public int countAllMatchedWikiUsers(String wikiName, Map<?, ?> matchFields) throws XWikiException
146    {
147  0 int count = 0;
148   
149  0 try {
150  0 count =
151    RightsManager.getInstance().countAllWikiUsersOrGroups(true, wikiName,
152    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
153    } catch (RightsManagerException e) {
154  0 logError(MessageFormat.format("Try to count all users in wiki [{0}]", new Object[] { wikiName }), e);
155    }
156   
157  0 return count;
158    }
159   
160    /**
161    * @return the number of users in the main wiki.
162    * @throws XWikiException error when getting number of users.
163    */
 
164  0 toggle public int countAllGlobalUsers() throws XWikiException
165    {
166  0 return countAllMatchedGlobalUsers(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 users in the main wiki.
176    * @throws XWikiException error when getting number of users.
177    */
 
178  0 toggle public int countAllMatchedGlobalUsers(Map<?, ?> matchFields) throws XWikiException
179    {
180  0 int count = 0;
181   
182  0 try {
183  0 count =
184    RightsManager.getInstance().countAllGlobalUsersOrGroups(true,
185    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
186    } catch (RightsManagerException e) {
187  0 logError("Try to count all users in main wiki", e);
188    }
189   
190  0 return count;
191    }
192   
193    /**
194    * @return the number of users in the current wiki.
195    * @throws XWikiException error when getting number of users.
196    */
 
197  0 toggle public int countAllLocalUsers() throws XWikiException
198    {
199  0 return countAllMatchedLocalUsers(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 users in the current wiki.
209    * @throws XWikiException error when getting number of users.
210    */
 
211  1 toggle public int countAllMatchedLocalUsers(Map<?, ?> matchFields) throws XWikiException
212    {
213  1 int count = 0;
214   
215  1 try {
216  1 count =
217    RightsManager.getInstance().countAllLocalUsersOrGroups(true,
218    RightsManagerPluginApi.createMatchingTable(matchFields), this.context);
219    } catch (RightsManagerException e) {
220  0 logError("Try to count all users in current wiki", e);
221    }
222   
223  1 return count;
224    }
225   
226    /**
227    * Get all users 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 user to return.
231    * @return a {@link List} of {@link String} containing user names.
232    * @throws XWikiException error when searching for users.
233    */
 
234  0 toggle public List<String> getAllUsersNames(int nb, int start) throws XWikiException
235    {
236  0 return getAllMatchedUsersNames(null, nb, start);
237    }
238   
239    /**
240    * Get all users names in the main wiki and the current wiki.
241    *
242    * @return a {@link List} of {@link String} containing user names.
243    * @throws XWikiException error when searching for users.
244    */
 
245  0 toggle public List<String> getAllUsersNames() throws XWikiException
246    {
247  0 return getAllMatchedUsersNames(null);
248    }
249   
250    /**
251    * Get all users 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 user names.
259    * @throws XWikiException error when searching for users.
260    */
 
261  0 toggle public List<String> getAllMatchedUsersNames(Map<?, ?> matchFields) throws XWikiException
262    {
263  0 return getAllMatchedUsersNames(matchFields, 0, 0, null);
264    }
265   
266    /**
267    * Get all users 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 user to return.
276    * @return a {@link List} of {@link String} containing user names.
277    * @throws XWikiException error when searching for users.
278    */
 
279  0 toggle public List<String> getAllMatchedUsersNames(Map<?, ?> matchFields, int nb, int start) throws XWikiException
280    {
281  0 return getAllMatchedUsersNames(matchFields, nb, start, null);
282    }
283   
284    /**
285    * Get all users 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 user 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 user names.
300    * @throws XWikiException error when searching for users.
301    */
 
302  0 toggle public List<String> getAllMatchedUsersNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
303    throws XWikiException
304    {
305  0 List<String> userList;
306   
307  0 try {
308  0 userList =
309    (List<String>) RightsManager.getInstance().getAllMatchedUsersOrGroups(true,
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 users names", e);
314   
315  0 userList = Collections.emptyList();
316    }
317   
318  0 return userList;
319    }
320   
321    /**
322    * Get all users 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 user to return.
326    * @return a {@link List} of {@link String} containing user names.
327    * @throws XWikiException error when searching for users.
328    */
 
329  0 toggle public List<String> getAllGlobalUsersNames(int nb, int start) throws XWikiException
330    {
331  0 return getAllMatchedGlobalUsersNames(null, nb, start);
332    }
333   
334    /**
335    * Get all users names in the main wiki.
336    *
337    * @return a {@link List} of {@link String} containing user names.
338    * @throws XWikiException error when searching for users.
339    */
 
340  0 toggle public List<String> getAllGlobalUsersNames() throws XWikiException
341    {
342  0 return getAllMatchedGlobalUsersNames(null);
343    }
344   
345    /**
346    * Get all users 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 user names.
354    * @throws XWikiException error when searching for users.
355    */
 
356  0 toggle public List<String> getAllMatchedGlobalUsersNames(Map<?, ?> matchFields) throws XWikiException
357    {
358  0 return getAllMatchedGlobalUsersNames(matchFields, 0, 0, null);
359    }
360   
361    /**
362    * Get all users 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 user to return.
371    * @return a {@link List} of {@link String} containing user names.
372    * @throws XWikiException error when searching for users.
373    */
 
374  0 toggle public List<String> getAllMatchedGlobalUsersNames(Map<?, ?> matchFields, int nb, int start)
375    throws XWikiException
376    {
377  0 return getAllMatchedGlobalUsersNames(matchFields, nb, start, null);
378    }
379   
380    /**
381    * Get all users 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 user 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 user names.
396    * @throws XWikiException error when searching for users.
397    */
 
398  0 toggle public List<String> getAllMatchedGlobalUsersNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
399    throws XWikiException
400    {
401  0 List<String> userList;
402   
403  0 try {
404  0 userList =
405    (List<String>) RightsManager.getInstance().getAllMatchedGlobalUsersOrGroups(true,
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 users names from global wiki", e);
410   
411  0 userList = Collections.emptyList();
412    }
413   
414  0 return userList;
415    }
416   
417    /**
418    * Get all users names in the provided wiki.
419    *
420    * @param wikiName the wiki where to search for users.
421    * @param nb the maximum number of result to return.
422    * @param start the index of the first found user to return.
423    * @return a {@link List} of {@link String} containing user names.
424    * @throws XWikiException error when searching for users.
425    */
 
426  0 toggle public List<String> getAllWikiUsersNames(String wikiName, int nb, int start) throws XWikiException
427    {
428  0 return getAllMatchedWikiUsersNames(wikiName, null, nb, start);
429    }
430   
431    /**
432    * Get all users names in the provided wiki.
433    *
434    * @param wikiName the wiki where to search for users.
435    * @return a {@link List} of {@link String} containing user names.
436    * @throws XWikiException error when searching for users.
437    */
 
438  0 toggle public List<String> getAllWikiUsersNames(String wikiName) throws XWikiException
439    {
440  0 return getAllMatchedWikiUsersNames(wikiName, null);
441    }
442   
443    /**
444    * Get all users names in the provided wiki.
445    *
446    * @param wikiName the wiki where to search for users.
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 user names.
453    * @throws XWikiException error when searching for users.
454    */
 
455  0 toggle public List<String> getAllMatchedWikiUsersNames(String wikiName, Map<?, ?> matchFields) throws XWikiException
456    {
457  0 return getAllMatchedWikiUsersNames(wikiName, matchFields, 0, 0, null);
458    }
459   
460    /**
461    * Get all users names in the provided wiki.
462    *
463    * @param wikiName the wiki where to search for users.
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 user to return.
471    * @return a {@link List} of {@link String} containing user names.
472    * @throws XWikiException error when searching for users.
473    */
 
474  0 toggle public List<String> getAllMatchedWikiUsersNames(String wikiName, Map<?, ?> matchFields, int nb, int start)
475    throws XWikiException
476    {
477  0 return getAllMatchedWikiUsersNames(wikiName, matchFields, nb, start, null);
478    }
479   
480    /**
481    * Get all users names in the provided wiki.
482    *
483    * @param wikiName the wiki where to search for users.
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 user 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 user names.
497    * @throws XWikiException error when searching for users.
498    */
 
499  0 toggle public List<String> getAllMatchedWikiUsersNames(String wikiName, Map<?, ?> matchFields, int nb, int start,
500    List<?> order) throws XWikiException
501    {
502  0 List<String> userList;
503   
504  0 try {
505  0 userList =
506    (List<String>) RightsManager.getInstance().getAllMatchedWikiUsersOrGroups(true, 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 users names from provided wiki", e);
511   
512  0 userList = Collections.emptyList();
513    }
514   
515  0 return userList;
516    }
517   
518    /**
519    * Get all users 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 user to return.
523    * @return a {@link List} of {@link String} containing user names.
524    * @throws XWikiException error when searching for users.
525    */
 
526  0 toggle public List<String> getAllLocalUsersNames(int nb, int start) throws XWikiException
527    {
528  0 return getAllMatchedLocalUsersNames(null, nb, start);
529    }
530   
531    /**
532    * Get all users names in the current wiki.
533    *
534    * @return a {@link List} of {@link String} containing user names.
535    * @throws XWikiException error when searching for users.
536    */
 
537  0 toggle public List<String> getAllLocalUsersNames() throws XWikiException
538    {
539  0 return getAllMatchedLocalUsersNames(null);
540    }
541   
542    /**
543    * Get all users 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 user names.
551    * @throws XWikiException error when searching for users.
552    */
 
553  0 toggle public List<String> getAllMatchedLocalUsersNames(Map<?, ?> matchFields) throws XWikiException
554    {
555  0 return getAllMatchedLocalUsersNames(matchFields, 0, 0, null);
556    }
557   
558    /**
559    * Get all users 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 user to return.
568    * @return a {@link List} of {@link String} containing user names.
569    * @throws XWikiException error when searching for users.
570    */
 
571  0 toggle public List<String> getAllMatchedLocalUsersNames(Map<?, ?> matchFields, int nb, int start) throws XWikiException
572    {
573  0 return getAllMatchedLocalUsersNames(matchFields, nb, start, null);
574    }
575   
576    /**
577    * Get all users names in the current wiki.
578    *
579    * @param matchFields the fields to match. It is a Map with field name as key and for value :
580    * <ul>
581    * <li>"matching string" for document fields</li>
582    * <li>or ["field type", "matching string"] for object fields</li>
583    * </ul>
584    * @param nb the maximum number of result to return.
585    * @param start the index of the first found user to return.
586    * @param order the fields to order from. It is a List containing :
587    * <ul>
588    * <li>"field name" for document fields</li>
589    * <li>or ["filed name", "field type"] for object fields</li>
590    * </ul>
591    * of {@link String} containing user names.
592    * @return a {@link List} of {@link String} containing user names.
593    * @throws XWikiException error when searching for users.
594    */
 
595  0 toggle public List<String> getAllMatchedLocalUsersNames(Map<?, ?> matchFields, int nb, int start, List<?> order)
596    throws XWikiException
597    {
598  0 List<String> userList;
599   
600  0 try {
601  0 userList =
602    (List<String>) RightsManager.getInstance().getAllMatchedLocalUsersOrGroups(true,
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 users names from local wiki", e);
607   
608  0 userList = Collections.emptyList();
609    }
610   
611  0 return userList;
612    }
613   
614    /**
615    * Get all users 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 user to return.
619    * @return a {@link List} of {@link Document} containing user.
620    * @throws XWikiException error when searching for users.
621    */
 
622  0 toggle public List<Document> getAllUsers(int nb, int start) throws XWikiException
623    {
624  0 return getAllMatchedUsers(null, nb, start);
625    }
626   
627    /**
628    * Get all users in the main wiki and the current wiki.
629    *
630    * @return a {@link List} of {@link Document} containing user.
631    * @throws XWikiException error when searching for users.
632    */
 
633  0 toggle public List<Document> getAllUsers() throws XWikiException
634    {
635  0 return getAllMatchedUsers(null);
636    }
637   
638    /**
639    * Get all users 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 user.
647    * @throws XWikiException error when searching for users.
648    */
 
649  0 toggle public List<Document> getAllMatchedUsers(Map<?, ?> matchFields) throws XWikiException
650    {
651  0 return getAllMatchedUsers(matchFields, 0, 0, null);
652    }
653   
654    /**
655    * Get all users 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 user to return.
664    * @return a {@link List} of {@link Document} containing user.
665    * @throws XWikiException error when searching for users.
666    */
 
667  0 toggle public List<Document> getAllMatchedUsers(Map<?, ?> matchFields, int nb, int start) throws XWikiException
668    {
669  0 return getAllMatchedUsers(matchFields, nb, start, null);
670    }
671   
672    /**
673    * Get all users 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 user 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 user.
688    * @throws XWikiException error when searching for users.
689    */
 
690  0 toggle public List<Document> getAllMatchedUsers(Map<?, ?> matchFields, int nb, int start, List<?> order)
691    throws XWikiException
692    {
693  0 List<Document> userList;
694   
695  0 try {
696  0 List<XWikiDocument> xdocList =
697    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedUsersOrGroups(true,
698    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
699    RightsManagerPluginApi.createOrderTable(order), this.context);
700   
701  0 userList = convert(xdocList);
702    } catch (RightsManagerException e) {
703  0 logError("Try to get all matched users", e);
704   
705  0 userList = Collections.emptyList();
706    }
707   
708  0 return userList;
709    }
710   
711    /**
712    * Get all users in the main wiki.
713    *
714    * @param nb the maximum number of result to return.
715    * @param start the index of the first found user to return.
716    * @return a {@link List} of {@link Document} containing user.
717    * @throws XWikiException error when searching for users.
718    */
 
719  0 toggle public List<Document> getAllGlobalUsers(int nb, int start) throws XWikiException
720    {
721  0 return getAllMatchedGlobalUsers(null, nb, start);
722    }
723   
724    /**
725    * Get all users in the main wiki.
726    *
727    * @return a {@link List} of {@link Document} containing user.
728    * @throws XWikiException error when searching for users.
729    */
 
730  0 toggle public List<Document> getAllGlobalUsers() throws XWikiException
731    {
732  0 return getAllMatchedGlobalUsers(null);
733    }
734   
735    /**
736    * Get all users 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 user.
744    * @throws XWikiException error when searching for users.
745    */
 
746  0 toggle public List<Document> getAllMatchedGlobalUsers(Map<?, ?> matchFields) throws XWikiException
747    {
748  0 return getAllMatchedGlobalUsers(matchFields, 0, 0, null);
749    }
750   
751    /**
752    * Get all users 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 user to return.
761    * @return a {@link List} of {@link Document} containing user.
762    * @throws XWikiException error when searching for users.
763    */
 
764  0 toggle public List<Document> getAllMatchedGlobalUsers(Map<?, ?> matchFields, int nb, int start) throws XWikiException
765    {
766  0 return getAllMatchedGlobalUsers(matchFields, nb, start, null);
767    }
768   
769    /**
770    * Get all users 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 user 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 user.
785    * @throws XWikiException error when searching for users.
786    */
 
787  0 toggle public List<Document> getAllMatchedGlobalUsers(Map<?, ?> matchFields, int nb, int start, List<?> order)
788    throws XWikiException
789    {
790  0 List<Document> userList;
791   
792  0 try {
793  0 List<XWikiDocument> xdocList =
794    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedGlobalUsersOrGroups(true,
795    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
796    RightsManagerPluginApi.createOrderTable(order), this.context);
797   
798  0 userList = convert(xdocList);
799    } catch (RightsManagerException e) {
800  0 logError("Try to get all matched users from global wiki", e);
801   
802  0 userList = Collections.emptyList();
803    }
804   
805  0 return userList;
806    }
807   
808    /**
809    * Get all users in the provided wiki.
810    *
811    * @param wikiName the wiki where to search for users.
812    * @param nb the maximum number of result to return.
813    * @param start the index of the first found user to return.
814    * @return a {@link List} of {@link Document} containing user.
815    * @throws XWikiException error when searching for users.
816    */
 
817  0 toggle public List<Document> getAllWikiUsers(String wikiName, int nb, int start) throws XWikiException
818    {
819  0 return getAllMatchedWikiUsers(wikiName, null, nb, start);
820    }
821   
822    /**
823    * Get all users in the provided wiki.
824    *
825    * @param wikiName the wiki where to search for users.
826    * @return a {@link List} of {@link Document} containing user.
827    * @throws XWikiException error when searching for users.
828    */
 
829  0 toggle public List<Document> getAllWikiUsers(String wikiName) throws XWikiException
830    {
831  0 return getAllMatchedWikiUsers(wikiName, null);
832    }
833   
834    /**
835    * Get all users in the provided wiki.
836    *
837    * @param wikiName the wiki where to search for users.
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 user.
844    * @throws XWikiException error when searching for users.
845    */
 
846  0 toggle public List<Document> getAllMatchedWikiUsers(String wikiName, Map<?, ?> matchFields) throws XWikiException
847    {
848  0 return getAllMatchedWikiUsers(wikiName, matchFields, 0, 0, null);
849    }
850   
851    /**
852    * Get all users in the provided wiki.
853    *
854    * @param wikiName the wiki where to search for users.
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 user to return.
862    * @return a {@link List} of {@link Document} containing user.
863    * @throws XWikiException error when searching for users.
864    */
 
865  0 toggle public List<Document> getAllMatchedWikiUsers(String wikiName, Map<?, ?> matchFields, int nb, int start)
866    throws XWikiException
867    {
868  0 return getAllMatchedWikiUsers(wikiName, matchFields, nb, start, null);
869    }
870   
871    /**
872    * Get all users in the provided wiki.
873    *
874    * @param wikiName the wiki where to search for users.
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 user 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 user.
888    * @throws XWikiException error when searching for users.
889    */
 
890  0 toggle public List<Document> getAllMatchedWikiUsers(String wikiName, Map<?, ?> matchFields, int nb, int start,
891    List<?> order) throws XWikiException
892    {
893  0 List<Document> userList;
894   
895  0 try {
896  0 List<XWikiDocument> xdocList =
897    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedWikiUsersOrGroups(true, wikiName,
898    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
899    RightsManagerPluginApi.createOrderTable(order), this.context);
900   
901  0 userList = convert(xdocList);
902    } catch (RightsManagerException e) {
903  0 logError("Try to get all matched users from provided wiki", e);
904   
905  0 userList = Collections.emptyList();
906    }
907   
908  0 return userList;
909    }
910   
911    /**
912    * Get all users in the current wiki.
913    *
914    * @param nb the maximum number of result to return.
915    * @param start the index of the first found user to return.
916    * @return a {@link List} of {@link Document} containing user.
917    * @throws XWikiException error when searching for users.
918    */
 
919  0 toggle public List<Document> getAllLocalUsers(int nb, int start) throws XWikiException
920    {
921  0 return getAllMatchedLocalUsers(null, nb, start);
922    }
923   
924    /**
925    * Get all users in the current wiki.
926    *
927    * @return a {@link List} of {@link Document} containing user.
928    * @throws XWikiException error when searching for users.
929    */
 
930  0 toggle public List<Document> getAllLocalUsers() throws XWikiException
931    {
932  0 return getAllMatchedLocalUsers(null);
933    }
934   
935    /**
936    * Get all users 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 user.
944    * @throws XWikiException error when searching for users.
945    */
 
946  0 toggle public List<Document> getAllMatchedLocalUsers(Map<?, ?> matchFields) throws XWikiException
947    {
948  0 return getAllMatchedLocalUsers(matchFields, 0, 0, null);
949    }
950   
951    /**
952    * Get all users 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 user to return.
961    * @return a {@link List} of {@link Document} containing user.
962    * @throws XWikiException error when searching for users.
963    */
 
964  0 toggle public List<Document> getAllMatchedLocalUsers(Map<?, ?> matchFields, int nb, int start) throws XWikiException
965    {
966  0 return getAllMatchedLocalUsers(matchFields, nb, start, null);
967    }
968   
969    /**
970    * Get all users 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 user 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 user.
985    * @throws XWikiException error when searching for users.
986    */
 
987  1 toggle public List<Document> getAllMatchedLocalUsers(Map<?, ?> matchFields, int nb, int start, List<?> order)
988    throws XWikiException
989    {
990  1 List<Document> userList;
991   
992  1 try {
993  1 List<XWikiDocument> xdocList =
994    (List<XWikiDocument>) RightsManager.getInstance().getAllMatchedLocalUsersOrGroups(true,
995    RightsManagerPluginApi.createMatchingTable(matchFields), true, new RequestLimit(nb, start),
996    RightsManagerPluginApi.createOrderTable(order), this.context);
997   
998  1 userList = convert(xdocList);
999    } catch (RightsManagerException e) {
1000  0 logError("Try to get all matched users from local wiki", e);
1001   
1002  0 userList = Collections.emptyList();
1003    }
1004   
1005  1 return userList;
1006    }
1007    }