1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package com.xpn.xwiki.plugin.rightsmanager; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Collection; |
25 |
|
import java.util.HashMap; |
26 |
|
import java.util.Iterator; |
27 |
|
import java.util.LinkedHashSet; |
28 |
|
import java.util.List; |
29 |
|
import java.util.Map; |
30 |
|
|
31 |
|
import org.apache.commons.lang3.StringUtils; |
32 |
|
import org.xwiki.model.reference.DocumentReference; |
33 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
34 |
|
import org.xwiki.model.reference.EntityReference; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWikiContext; |
37 |
|
import com.xpn.xwiki.XWikiException; |
38 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
39 |
|
import com.xpn.xwiki.internal.plugin.rightsmanager.ReferenceUserIterator; |
40 |
|
import com.xpn.xwiki.objects.BaseObject; |
41 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
42 |
|
import com.xpn.xwiki.objects.classes.ListClass; |
43 |
|
import com.xpn.xwiki.objects.classes.PropertyClass; |
44 |
|
import com.xpn.xwiki.plugin.rightsmanager.utils.AllowDeny; |
45 |
|
import com.xpn.xwiki.plugin.rightsmanager.utils.LevelTree; |
46 |
|
import com.xpn.xwiki.plugin.rightsmanager.utils.RequestLimit; |
47 |
|
import com.xpn.xwiki.plugin.rightsmanager.utils.UsersGroups; |
48 |
|
import com.xpn.xwiki.user.impl.xwiki.XWikiRightServiceImpl; |
49 |
|
import com.xpn.xwiki.web.Utils; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@version |
55 |
|
@since |
56 |
|
@since |
57 |
|
|
|
|
| 10% |
Uncovered Elements: 351 (390) |
Complexity: 108 |
Complexity Density: 0.47 |
|
58 |
|
public final class RightsManager |
59 |
|
{ |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
public static final String DEFAULT_USERORGROUP_SPACE = "XWiki"; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
private static final String WIKIFULLNAME_SEP = ":"; |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
private static final String SPACEPAGENAME_SEP = "."; |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
private static final String WIKI_PREFERENCES = "XWiki.XWikiPreferences"; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
private static final String SPACE_PREFERENCES = "WebPreferences"; |
84 |
|
|
85 |
|
|
86 |
|
@link@link |
87 |
|
|
88 |
|
private static final String RIGHTSFIELD_LEVELS = "levels"; |
89 |
|
|
90 |
|
|
91 |
|
@link@link |
92 |
|
|
93 |
|
private static final String RIGHTSFIELD_USERS = "users"; |
94 |
|
|
95 |
|
|
96 |
|
@link@link |
97 |
|
|
98 |
|
private static final String RIGHTSFIELD_GROUPS = "groups"; |
99 |
|
|
100 |
|
|
101 |
|
@link@link |
102 |
|
|
103 |
|
private static final String RIGHTSFIELD_ALLOW = "allow"; |
104 |
|
|
105 |
|
|
106 |
|
@link@link |
107 |
|
|
108 |
|
private static final String RIGHTSLISTFIELD_SEP = ",|"; |
109 |
|
|
110 |
|
|
111 |
|
@link@link |
112 |
|
|
113 |
|
private static final String RIGHTSLISTFIELD_JOIN = "|"; |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
private static final String HQLLIKE_ALL_SYMBOL = "%"; |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
private static RightsManager instance; |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
private DocumentReferenceResolver<String> explicitDocumentReferenceResolver = Utils.getComponent( |
131 |
|
DocumentReferenceResolver.TYPE_STRING, "explicit"); |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
private DocumentReferenceResolver<String> currentDocumentReferenceResolver = Utils.getComponent( |
137 |
|
DocumentReferenceResolver.TYPE_STRING, "current"); |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
142 |
3 |
private RightsManager()... |
143 |
|
{ |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
@return |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
149 |
33 |
public static RightsManager getInstance()... |
150 |
|
{ |
151 |
33 |
synchronized (RightsManager.class) { |
152 |
33 |
if (instance == null) { |
153 |
3 |
instance = new RightsManager(); |
154 |
|
} |
155 |
|
} |
156 |
|
|
157 |
33 |
return instance; |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
@param |
166 |
|
@param |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
@param |
173 |
|
@return |
174 |
|
@throws |
175 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
176 |
0 |
public int countAllUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context) throws XWikiException... |
177 |
|
{ |
178 |
0 |
if (context.isMainWiki()) { |
179 |
0 |
return countAllLocalUsersOrGroups(user, matchFields, context); |
180 |
|
} |
181 |
|
|
182 |
0 |
return countAllGlobalUsersOrGroups(user, matchFields, context) |
183 |
|
+ countAllLocalUsersOrGroups(user, matchFields, context); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
@param |
190 |
|
@param |
191 |
|
@param |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
@return |
199 |
|
@throws |
200 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
201 |
0 |
public int countAllWikiUsersOrGroups(boolean user, String wikiName, Object[][] matchFields, XWikiContext context)... |
202 |
|
throws XWikiException |
203 |
|
{ |
204 |
0 |
if (context.isMainWiki()) { |
205 |
0 |
return countAllLocalUsersOrGroups(user, matchFields, context); |
206 |
|
} |
207 |
|
|
208 |
0 |
String database = context.getWikiId(); |
209 |
|
|
210 |
0 |
try { |
211 |
0 |
context.setWikiId(wikiName); |
212 |
0 |
return countAllLocalUsersOrGroups(user, matchFields, context); |
213 |
|
} finally { |
214 |
0 |
context.setWikiId(database); |
215 |
|
} |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
@param |
222 |
|
@param |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@param |
229 |
|
@return |
230 |
|
@throws |
231 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
232 |
0 |
public int countAllGlobalUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context)... |
233 |
|
throws XWikiException |
234 |
|
{ |
235 |
0 |
if (context.isMainWiki()) { |
236 |
0 |
return countAllLocalUsersOrGroups(user, matchFields, context); |
237 |
|
} |
238 |
|
|
239 |
0 |
return countAllWikiUsersOrGroups(user, context.getMainXWiki(), matchFields, context); |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
@param |
246 |
|
@param |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
@param |
253 |
|
@return |
254 |
|
@throws |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
256 |
5 |
public int countAllLocalUsersOrGroups(boolean user, Object[][] matchFields, XWikiContext context)... |
257 |
|
throws XWikiException |
258 |
|
{ |
259 |
5 |
if (user) { |
260 |
1 |
return context.getWiki().getGroupService(context).countAllMatchedUsers(matchFields, context); |
261 |
|
} else { |
262 |
4 |
return context.getWiki().getGroupService(context).countAllMatchedGroups(matchFields, context); |
263 |
|
} |
264 |
|
} |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
@param |
270 |
|
@param |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
@param@link@link@link |
277 |
|
@link |
278 |
|
@param |
279 |
|
@param |
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
@param |
285 |
|
@return@link@link |
286 |
|
@link@link |
287 |
|
@throws |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
289 |
0 |
public List<?> getAllMatchedUsersOrGroups(boolean user, Object[][] matchFields, boolean withdetails,... |
290 |
|
RequestLimit limit, Object[][] order, XWikiContext context) throws XWikiException |
291 |
|
{ |
292 |
0 |
if (context.isMainWiki()) { |
293 |
0 |
return getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, limit, order, context); |
294 |
|
} |
295 |
|
|
296 |
0 |
List<Object> userOrGroupList = new ArrayList<Object>(); |
297 |
|
|
298 |
0 |
int nbGlobalUsersOrGroups = countAllGlobalUsersOrGroups(user, null, context); |
299 |
|
|
300 |
0 |
int newstart = limit.getStart(); |
301 |
|
|
302 |
|
|
303 |
0 |
if (newstart < nbGlobalUsersOrGroups) { |
304 |
0 |
userOrGroupList.addAll(getAllMatchedGlobalUsersOrGroups(user, matchFields, withdetails, new RequestLimit( |
305 |
|
limit.getNb(), newstart), order, context)); |
306 |
0 |
newstart = 0; |
307 |
|
} else { |
308 |
0 |
newstart = newstart - nbGlobalUsersOrGroups; |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
0 |
if (limit.getNb() > userOrGroupList.size()) { |
313 |
0 |
userOrGroupList.addAll(getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, new RequestLimit( |
314 |
|
limit.getNb() - userOrGroupList.size(), newstart), order, context)); |
315 |
0 |
} else if (limit.getNb() <= 0) { |
316 |
0 |
userOrGroupList.addAll(getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, new RequestLimit(0, |
317 |
|
newstart), order, context)); |
318 |
|
} |
319 |
|
|
320 |
0 |
return userOrGroupList; |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
@param |
327 |
|
@param |
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
@param@link@link@link |
334 |
|
@link |
335 |
|
@param |
336 |
|
@param |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
@param |
342 |
|
@return@link@link |
343 |
|
@link@link |
344 |
|
@throws |
345 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
346 |
0 |
public List<?> getAllMatchedGlobalUsersOrGroups(boolean user, Object[][] matchFields, boolean withdetails,... |
347 |
|
RequestLimit limit, Object[][] order, XWikiContext context) throws XWikiException |
348 |
|
{ |
349 |
0 |
if (context.isMainWiki()) { |
350 |
0 |
return getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, limit, order, context); |
351 |
|
} |
352 |
|
|
353 |
0 |
return getAllMatchedWikiUsersOrGroups(user, context.getMainXWiki(), matchFields, withdetails, limit, order, |
354 |
|
context); |
355 |
|
} |
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
@param |
361 |
|
@param |
362 |
|
@param |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
@param@link@link@link |
369 |
|
@link |
370 |
|
@param |
371 |
|
@param |
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
|
376 |
|
@param |
377 |
|
@return@link@link |
378 |
|
@link@link |
379 |
|
@throws |
380 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
381 |
0 |
public List<?> getAllMatchedWikiUsersOrGroups(boolean user, String wikiName, Object[][] matchFields,... |
382 |
|
boolean withdetails, RequestLimit limit, Object[][] order, XWikiContext context) throws XWikiException |
383 |
|
{ |
384 |
0 |
if (context.isMainWiki()) { |
385 |
0 |
return getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, limit, order, context); |
386 |
|
} |
387 |
|
|
388 |
0 |
String database = context.getWikiId(); |
389 |
|
|
390 |
0 |
try { |
391 |
0 |
context.setWikiId(wikiName); |
392 |
|
|
393 |
0 |
List<?> localGroupList = |
394 |
|
getAllMatchedLocalUsersOrGroups(user, matchFields, withdetails, limit, order, context); |
395 |
|
|
396 |
0 |
if (localGroupList != null && !withdetails) { |
397 |
0 |
List<String> wikiGroupList = new ArrayList<String>(localGroupList.size()); |
398 |
0 |
for (Object groupName : localGroupList) { |
399 |
0 |
wikiGroupList.add(wikiName + WIKIFULLNAME_SEP + groupName); |
400 |
|
} |
401 |
|
|
402 |
0 |
localGroupList = wikiGroupList; |
403 |
|
} |
404 |
|
|
405 |
0 |
return localGroupList; |
406 |
|
} finally { |
407 |
0 |
context.setWikiId(database); |
408 |
|
} |
409 |
|
} |
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
@param |
415 |
|
@param |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
@param@link@link@link |
422 |
|
@link |
423 |
|
@param |
424 |
|
@param |
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
@param |
430 |
|
@return@link@link |
431 |
|
@link@link |
432 |
|
@throws |
433 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
434 |
5 |
public List<?> getAllMatchedLocalUsersOrGroups(boolean user, Object[][] matchFields, boolean withdetails,... |
435 |
|
RequestLimit limit, Object[][] order, XWikiContext context) throws XWikiException |
436 |
|
{ |
437 |
5 |
if (user) { |
438 |
1 |
return context.getWiki().getGroupService(context) |
439 |
|
.getAllMatchedUsers(matchFields, withdetails, limit.getNb(), limit.getStart(), order, context); |
440 |
|
} else { |
441 |
4 |
return context.getWiki().getGroupService(context) |
442 |
|
.getAllMatchedGroups(matchFields, withdetails, limit.getNb(), limit.getStart(), order, context); |
443 |
|
} |
444 |
|
} |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
@param |
450 |
|
@param |
451 |
|
@param |
452 |
|
@param |
453 |
|
@return@link@link |
454 |
|
@throws |
455 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
456 |
0 |
public Collection<String> getAllGroupsNamesForMember(String member, int nb, int start, XWikiContext context)... |
457 |
|
throws XWikiException |
458 |
|
{ |
459 |
0 |
return context.getWiki().getGroupService(context).getAllGroupsNamesForMember(member, nb, start, context); |
460 |
|
} |
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
@param |
466 |
|
@param |
467 |
|
@param |
468 |
|
@param |
469 |
|
@return@link@link |
470 |
|
@throws |
471 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
472 |
0 |
public Collection<String> getAllMembersNamesForGroup(String group, int nb, int start, XWikiContext context)... |
473 |
|
throws XWikiException |
474 |
|
{ |
475 |
0 |
return context.getWiki().getGroupService(context).getAllMembersNamesForGroup(group, nb, start, context); |
476 |
|
} |
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
@param |
482 |
|
@param |
483 |
|
@param |
484 |
|
@param |
485 |
|
@param |
486 |
|
@param |
487 |
|
@return@link@link |
488 |
|
@throws |
489 |
|
@since |
490 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
491 |
7 |
public Collection<String> getAllMatchedMembersNamesForGroup(String group, String matchField, int nb, int start,... |
492 |
|
Boolean orderAsc, XWikiContext context) throws XWikiException |
493 |
|
{ |
494 |
7 |
return context.getWiki().getGroupService(context) |
495 |
|
.getAllMatchedMembersNamesForGroup(group, matchField, nb, start, orderAsc, context); |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
@param |
502 |
|
@param |
503 |
|
@return |
504 |
|
@throws |
505 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
506 |
0 |
public int countAllGroupsNamesForMember(String member, XWikiContext context) throws XWikiException... |
507 |
|
{ |
508 |
0 |
return context.getWiki().getGroupService(context).countAllGroupsNamesForMember(member, context); |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
@param |
515 |
|
@param |
516 |
|
@return |
517 |
|
@throws |
518 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
519 |
9 |
public int countAllMembersNamesForGroup(String group, XWikiContext context) throws XWikiException... |
520 |
|
{ |
521 |
9 |
return context.getWiki().getGroupService(context).countAllMembersNamesForGroup(group, context); |
522 |
|
} |
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
@link@link |
528 |
|
|
529 |
|
@param |
530 |
|
@param |
531 |
|
@param |
532 |
|
@param |
533 |
|
@return@link@link |
534 |
|
@throws |
535 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
536 |
0 |
private Map<String, LevelTree> getLevelTreeMap(XWikiDocument preferences, List<String> levelsToMatch,... |
537 |
|
boolean global, XWikiContext context) throws XWikiException |
538 |
|
{ |
539 |
0 |
Map<String, LevelTree> rightsMap = new HashMap<String, LevelTree>(); |
540 |
|
|
541 |
0 |
fillLevelTreeMap(rightsMap, preferences, levelsToMatch, global, true, context); |
542 |
|
|
543 |
0 |
return rightsMap; |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
|
@link@link |
548 |
|
|
549 |
|
@param |
550 |
|
@param |
551 |
|
@param |
552 |
|
@return@link@link |
553 |
|
@throws |
554 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
555 |
0 |
public Map<String, LevelTree> getLevelTreeMap(String spaceOrPage, List<String> levelsToMatch, XWikiContext context)... |
556 |
|
throws XWikiException |
557 |
|
{ |
558 |
0 |
XWikiDocument preferences = getXWikiPreferencesDoc(spaceOrPage, context); |
559 |
|
|
560 |
0 |
return getLevelTreeMap(preferences, levelsToMatch, isGlobal(preferences, spaceOrPage), context); |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
|
@link@link |
565 |
|
|
566 |
|
@param@link@link |
567 |
|
@param |
568 |
|
@param |
569 |
|
@param |
570 |
|
@param@link@link |
571 |
|
@param |
572 |
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 9 |
Complexity Density: 0.38 |
|
573 |
0 |
private void fillLevelTreeMap(Map<String, LevelTree> rightsMap, List<String> levelInherited, BaseObject bobj,... |
574 |
|
List<String> levelsToMatch, boolean direct, XWikiContext context) |
575 |
|
{ |
576 |
0 |
List<String> users = |
577 |
|
ListClass.getListFromString(bobj.getStringValue(RIGHTSFIELD_USERS), RIGHTSLISTFIELD_SEP, false); |
578 |
0 |
List<String> groups = |
579 |
|
ListClass.getListFromString(bobj.getStringValue(RIGHTSFIELD_GROUPS), RIGHTSLISTFIELD_SEP, false); |
580 |
0 |
List<String> levels = |
581 |
|
ListClass.getListFromString(bobj.getStringValue(RIGHTSFIELD_LEVELS), RIGHTSLISTFIELD_SEP, false); |
582 |
0 |
boolean allow = (bobj.getIntValue(RIGHTSFIELD_ALLOW) == 1); |
583 |
|
|
584 |
0 |
for (String levelName : levels) { |
585 |
0 |
if (levelsToMatch == null || levelsToMatch.contains(levelName)) { |
586 |
0 |
LevelTree level; |
587 |
0 |
if (!rightsMap.containsKey(levelName)) { |
588 |
0 |
level = new LevelTree(); |
589 |
0 |
rightsMap.put(levelName, level); |
590 |
|
} else { |
591 |
0 |
level = rightsMap.get(levelName); |
592 |
|
} |
593 |
|
|
594 |
0 |
AllowDeny allowdeny; |
595 |
0 |
if (direct) { |
596 |
0 |
if (levelInherited != null) { |
597 |
0 |
levelInherited.add(levelName); |
598 |
|
} |
599 |
|
|
600 |
0 |
if (level.direct == null) { |
601 |
0 |
level.direct = new AllowDeny(); |
602 |
|
} |
603 |
0 |
allowdeny = level.direct; |
604 |
|
} else { |
605 |
0 |
if (level.inherited == null) { |
606 |
0 |
level.inherited = new AllowDeny(); |
607 |
|
} |
608 |
0 |
allowdeny = level.inherited; |
609 |
|
} |
610 |
|
|
611 |
0 |
UsersGroups usersgroups = allow ? allowdeny.allow : allowdeny.deny; |
612 |
|
|
613 |
0 |
usersgroups.users.addAll(users); |
614 |
0 |
usersgroups.groups.addAll(groups); |
615 |
|
} |
616 |
|
} |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
|
@link@link |
621 |
|
|
622 |
|
@param@link@link |
623 |
|
@param |
624 |
|
@param |
625 |
|
@param |
626 |
|
@param |
627 |
|
@param |
628 |
|
@throws |
629 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.6 |
|
630 |
0 |
private void fillLevelTreeMapInherited(Map<String, LevelTree> rightsMap, List<String> levelInheritedIn,... |
631 |
|
XWikiDocument preferences, List<String> levelsToMatch, boolean global, XWikiContext context) |
632 |
|
throws XWikiException |
633 |
|
{ |
634 |
0 |
List<String> levelInherited = levelInheritedIn; |
635 |
|
|
636 |
|
|
637 |
0 |
XWikiDocument parentPreferences = getParentPreference(preferences, global, context); |
638 |
|
|
639 |
0 |
if (parentPreferences != null) { |
640 |
|
|
641 |
0 |
if (levelInherited == null) { |
642 |
0 |
levelInherited = new ArrayList<String>(); |
643 |
|
} |
644 |
|
|
645 |
0 |
for (String levelName : levelsToMatch) { |
646 |
0 |
if (!rightsMap.containsKey(levelName) || (rightsMap.get(levelName)).inherited == null) { |
647 |
0 |
levelInherited.add(levelName); |
648 |
|
} |
649 |
|
} |
650 |
|
|
651 |
|
|
652 |
0 |
if (!levelInherited.isEmpty()) { |
653 |
0 |
fillLevelTreeMap(rightsMap, parentPreferences, levelInherited, true, false, context); |
654 |
|
} |
655 |
|
} |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
|
@link@link |
660 |
|
|
661 |
|
@param@link@link |
662 |
|
@param |
663 |
|
@param |
664 |
|
@param |
665 |
|
@param@link@link |
666 |
|
@param |
667 |
|
@throws |
668 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
669 |
0 |
private void fillLevelTreeMap(Map<String, LevelTree> rightsMap, XWikiDocument preferences,... |
670 |
|
List<String> levelsToMatch, boolean global, boolean direct, XWikiContext context) throws XWikiException |
671 |
|
{ |
672 |
0 |
List<String> levelInherited = null; |
673 |
0 |
if (levelsToMatch == null) { |
674 |
0 |
levelInherited = new ArrayList<String>(); |
675 |
|
} |
676 |
|
|
677 |
0 |
if (!preferences.isNew()) { |
678 |
0 |
EntityReference rightClassReference = |
679 |
0 |
global ? XWikiRightServiceImpl.GLOBALRIGHTCLASS_REFERENCE |
680 |
|
: XWikiRightServiceImpl.RIGHTCLASS_REFERENCE; |
681 |
0 |
List<BaseObject> rightObjects = preferences.getXObjects(rightClassReference); |
682 |
0 |
if (rightObjects != null) { |
683 |
0 |
for (BaseObject bobj : rightObjects) { |
684 |
0 |
fillLevelTreeMap(rightsMap, levelInherited, bobj, levelsToMatch, direct, context); |
685 |
|
} |
686 |
|
} |
687 |
|
} |
688 |
|
|
689 |
0 |
fillLevelTreeMapInherited(rightsMap, levelInherited, preferences, levelsToMatch, global, context); |
690 |
|
} |
691 |
|
|
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
@param |
696 |
|
@param |
697 |
|
@param |
698 |
|
@return |
699 |
|
@throws |
700 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 7 |
Complexity Density: 0.5 |
|
701 |
0 |
public XWikiDocument getParentPreference(XWikiDocument currentPreference, boolean currentGlobal,... |
702 |
|
XWikiContext context) throws XWikiException |
703 |
|
{ |
704 |
0 |
XWikiDocument parentPreferences = null; |
705 |
|
|
706 |
0 |
if (currentGlobal) { |
707 |
0 |
if (currentPreference.getFullName().equals(WIKI_PREFERENCES)) { |
708 |
0 |
if (!context.isMainWiki()) { |
709 |
0 |
parentPreferences = |
710 |
|
context.getWiki().getDocument(context.getMainXWiki() + WIKIFULLNAME_SEP + WIKI_PREFERENCES, |
711 |
|
context); |
712 |
|
} |
713 |
0 |
} else if (currentPreference.getName().equals(SPACE_PREFERENCES)) { |
714 |
0 |
String parentspace = currentPreference.getStringValue(WIKI_PREFERENCES, "parent"); |
715 |
0 |
if (parentspace.trim().length() > 0) { |
716 |
0 |
parentPreferences = |
717 |
|
context.getWiki().getDocument(parentspace + SPACEPAGENAME_SEP + SPACE_PREFERENCES, context); |
718 |
|
} else { |
719 |
0 |
parentPreferences = context.getWiki().getDocument(WIKI_PREFERENCES, context); |
720 |
|
} |
721 |
|
|
722 |
0 |
if (parentPreferences == currentPreference) { |
723 |
0 |
parentPreferences = null; |
724 |
|
} |
725 |
|
} |
726 |
|
} else { |
727 |
0 |
parentPreferences = |
728 |
|
context.getWiki().getDocument(currentPreference.getSpace() + SPACEPAGENAME_SEP + SPACE_PREFERENCES, |
729 |
|
context); |
730 |
|
} |
731 |
|
|
732 |
0 |
return parentPreferences; |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
@param |
739 |
|
@param |
740 |
|
@return |
741 |
|
@throws |
742 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
743 |
0 |
public XWikiDocument getParentPreference(String spaceOrPage, XWikiContext context) throws XWikiException... |
744 |
|
{ |
745 |
0 |
XWikiDocument preferences = getXWikiPreferencesDoc(spaceOrPage, context); |
746 |
|
|
747 |
0 |
boolean global = isGlobal(preferences, spaceOrPage); |
748 |
|
|
749 |
0 |
return getParentPreference(preferences, global, context); |
750 |
|
} |
751 |
|
|
752 |
|
|
753 |
|
|
754 |
|
|
755 |
|
@param |
756 |
|
@param |
757 |
|
@param |
758 |
|
@param |
759 |
|
@return@link |
760 |
|
@throws |
761 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
762 |
0 |
private LevelTree getLevel(XWikiDocument doc, String levelName, boolean global, XWikiContext context)... |
763 |
|
throws XWikiException |
764 |
|
{ |
765 |
0 |
if (doc.isNew()) { |
766 |
0 |
return null; |
767 |
|
} |
768 |
|
|
769 |
0 |
List<String> rights = new ArrayList<String>(); |
770 |
0 |
rights.add(levelName); |
771 |
|
|
772 |
0 |
Map<String, LevelTree> rightsMap = getLevelTreeMap(doc, rights, global, context); |
773 |
|
|
774 |
0 |
return rightsMap.get(levelName); |
775 |
|
} |
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
@param |
781 |
|
@param |
782 |
|
@return |
783 |
|
@throws |
784 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
785 |
0 |
private XWikiDocument getXWikiPreferencesDoc(String spaceOrPage, XWikiContext context) throws XWikiException... |
786 |
|
{ |
787 |
0 |
XWikiDocument xwikidoc = null; |
788 |
|
|
789 |
0 |
if (spaceOrPage != null) { |
790 |
0 |
xwikidoc = context.getWiki().getDocument(spaceOrPage, context); |
791 |
|
|
792 |
0 |
if (xwikidoc.isNew()) { |
793 |
0 |
xwikidoc = context.getWiki().getDocument(spaceOrPage + SPACEPAGENAME_SEP + SPACE_PREFERENCES, context); |
794 |
|
} |
795 |
|
} else { |
796 |
0 |
xwikidoc = context.getWiki().getDocument(WIKI_PREFERENCES, context); |
797 |
|
} |
798 |
|
|
799 |
0 |
return xwikidoc; |
800 |
|
} |
801 |
|
|
802 |
|
|
803 |
|
|
804 |
|
|
805 |
|
@param |
806 |
|
@param |
807 |
|
@return |
808 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
809 |
0 |
private boolean isGlobal(XWikiDocument preferences, String spaceOrPage)... |
810 |
|
{ |
811 |
0 |
return !preferences.getFullName().equals(spaceOrPage); |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
@param |
818 |
|
@param |
819 |
|
@param |
820 |
|
@return@link |
821 |
|
@throws |
822 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
823 |
0 |
public LevelTree getTreeLevel(String spaceOrPage, String levelName, XWikiContext context) throws XWikiException... |
824 |
|
{ |
825 |
0 |
XWikiDocument preferences = getXWikiPreferencesDoc(spaceOrPage, context); |
826 |
|
|
827 |
0 |
return getLevel(preferences, levelName, isGlobal(preferences, spaceOrPage), context); |
828 |
|
} |
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
|
@param |
834 |
|
@param |
835 |
|
@param |
836 |
|
@param |
837 |
|
@param |
838 |
|
@param |
839 |
|
@param |
840 |
|
@throws |
841 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
842 |
0 |
public void removeUserOrGroupFromLevel(String spaceOrPage, String userOrGroup, boolean user, String levelName,... |
843 |
|
boolean allow, String comment, XWikiContext context) throws XWikiException |
844 |
|
{ |
845 |
0 |
XWikiDocument preferences = getXWikiPreferencesDoc(spaceOrPage, context); |
846 |
|
|
847 |
0 |
boolean global = isGlobal(preferences, spaceOrPage); |
848 |
|
|
849 |
0 |
EntityReference rightClassReference = |
850 |
0 |
global ? XWikiRightServiceImpl.GLOBALRIGHTCLASS_REFERENCE : XWikiRightServiceImpl.RIGHTCLASS_REFERENCE; |
851 |
|
|
852 |
0 |
boolean needUpdate = false; |
853 |
|
|
854 |
0 |
List<BaseObject> rightObjects = preferences.getXObjects(rightClassReference); |
855 |
0 |
if (rightObjects != null) { |
856 |
0 |
for (BaseObject bobj : rightObjects) { |
857 |
0 |
List<String> levels = |
858 |
|
ListClass.getListFromString(bobj.getStringValue(RIGHTSFIELD_LEVELS), RIGHTSLISTFIELD_SEP, false); |
859 |
|
|
860 |
0 |
if (levels.contains(levelName)) { |
861 |
0 |
needUpdate |= removeUserOrGroupFromRight(bobj, null, null, userOrGroup, user, context); |
862 |
|
} |
863 |
|
} |
864 |
|
|
865 |
0 |
if (needUpdate) { |
866 |
0 |
context.getWiki().saveDocument(preferences, comment, context); |
867 |
|
} |
868 |
|
} |
869 |
|
} |
870 |
|
|
871 |
|
|
872 |
|
|
873 |
|
|
874 |
|
@param |
875 |
|
@param |
876 |
|
@param |
877 |
|
@param |
878 |
|
@param |
879 |
|
@param |
880 |
|
@return |
881 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 8 |
Complexity Density: 0.67 |
|
882 |
0 |
public boolean removeUserOrGroupFromRight(BaseObject right, String userOrGroupWiki, String userOrGroupSpace,... |
883 |
|
String userOrGroupName, boolean user, XWikiContext context) |
884 |
|
{ |
885 |
0 |
boolean needUpdate = false; |
886 |
|
|
887 |
0 |
String userOrGroupField = user ? RIGHTSFIELD_USERS : RIGHTSFIELD_GROUPS; |
888 |
|
|
889 |
0 |
List<String> usersOrGroups = |
890 |
|
ListClass.getListFromString(right.getStringValue(userOrGroupField), RIGHTSLISTFIELD_SEP, false); |
891 |
|
|
892 |
0 |
if (userOrGroupWiki != null) { |
893 |
0 |
needUpdate |= usersOrGroups.remove(userOrGroupWiki + WIKIFULLNAME_SEP + userOrGroupName); |
894 |
|
} |
895 |
|
|
896 |
0 |
if (context.getWikiId() == null || context.getWikiId().equalsIgnoreCase(userOrGroupWiki)) { |
897 |
0 |
needUpdate |= usersOrGroups.remove(userOrGroupName); |
898 |
|
|
899 |
0 |
if (userOrGroupSpace == null || userOrGroupSpace.equals(DEFAULT_USERORGROUP_SPACE)) { |
900 |
0 |
needUpdate |= usersOrGroups.remove(userOrGroupSpace + SPACEPAGENAME_SEP + userOrGroupName); |
901 |
|
} |
902 |
|
} |
903 |
|
|
904 |
0 |
if (needUpdate) { |
905 |
0 |
right.setStringValue(userOrGroupField, StringUtils.join(usersOrGroups.toArray(), RIGHTSLISTFIELD_JOIN)); |
906 |
|
} |
907 |
|
|
908 |
0 |
return needUpdate; |
909 |
|
} |
910 |
|
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
|
@param |
915 |
|
@param |
916 |
|
@param |
917 |
|
@param |
918 |
|
@param |
919 |
|
@param |
920 |
|
@param |
921 |
|
@return |
922 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 7 |
Complexity Density: 0.64 |
|
923 |
0 |
public boolean removeUserOrGroupFromRights(XWikiDocument rightsDocument, String userOrGroupWiki,... |
924 |
|
String userOrGroupSpace, String userOrGroupName, boolean user, boolean global, XWikiContext context) |
925 |
|
{ |
926 |
0 |
boolean needUpdate = false; |
927 |
|
|
928 |
0 |
EntityReference rightClassReference = |
929 |
0 |
global ? XWikiRightServiceImpl.GLOBALRIGHTCLASS_REFERENCE : XWikiRightServiceImpl.RIGHTCLASS_REFERENCE; |
930 |
|
|
931 |
0 |
List<BaseObject> rightObjects = rightsDocument.getXObjects(rightClassReference); |
932 |
0 |
if (rightObjects != null) { |
933 |
0 |
for (BaseObject bobj : rightObjects) { |
934 |
0 |
if (bobj == null) { |
935 |
0 |
continue; |
936 |
|
} |
937 |
0 |
needUpdate |= |
938 |
|
removeUserOrGroupFromRight(bobj, userOrGroupWiki, userOrGroupSpace, userOrGroupName, user, context); |
939 |
|
|
940 |
0 |
if (needUpdate && bobj.getStringValue(RIGHTSFIELD_USERS).trim().length() == 0 |
941 |
|
&& bobj.getStringValue(RIGHTSFIELD_GROUPS).trim().length() == 0) { |
942 |
0 |
rightsDocument.removeXObject(bobj); |
943 |
|
} |
944 |
|
} |
945 |
|
} |
946 |
|
|
947 |
0 |
return needUpdate; |
948 |
|
} |
949 |
|
|
950 |
|
|
951 |
|
|
952 |
|
|
953 |
|
@param |
954 |
|
@param |
955 |
|
@param |
956 |
|
@param |
957 |
|
@param |
958 |
|
@param |
959 |
|
@return |
960 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
961 |
0 |
public boolean removeUserOrGroupFromAllRights(XWikiDocument rightsDocument, String userOrGroupWiki,... |
962 |
|
String userOrGroupSpace, String userOrGroupName, boolean user, XWikiContext context) |
963 |
|
{ |
964 |
0 |
return removeUserOrGroupFromRights(rightsDocument, userOrGroupWiki, userOrGroupSpace, userOrGroupName, user, |
965 |
|
true, context) |
966 |
|
|| removeUserOrGroupFromRights(rightsDocument, userOrGroupWiki, userOrGroupSpace, userOrGroupName, user, |
967 |
|
false, context); |
968 |
|
} |
969 |
|
|
970 |
|
|
971 |
|
|
972 |
|
|
973 |
|
@param |
974 |
|
@param |
975 |
|
@param |
976 |
|
@param |
977 |
|
@param |
978 |
|
@throws |
979 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 7 |
Complexity Density: 0.29 |
|
980 |
0 |
public void removeUserOrGroupFromAllRights(String userOrGroupWiki, String userOrGroupSpace, String userOrGroupName,... |
981 |
|
boolean user, XWikiContext context) throws XWikiException |
982 |
|
{ |
983 |
0 |
List<String> parameterValues = new ArrayList<String>(); |
984 |
|
|
985 |
0 |
String fieldName; |
986 |
0 |
if (user) { |
987 |
0 |
fieldName = RIGHTSFIELD_USERS; |
988 |
|
} else { |
989 |
0 |
fieldName = RIGHTSFIELD_GROUPS; |
990 |
|
} |
991 |
|
|
992 |
0 |
BaseClass rightClass = context.getWiki().getRightsClass(context); |
993 |
0 |
BaseClass globalRightClass = context.getWiki().getGlobalRightsClass(context); |
994 |
|
|
995 |
0 |
String fieldTypeName = ((PropertyClass) rightClass.get(fieldName)).newProperty().getClass().getSimpleName(); |
996 |
|
|
997 |
0 |
StringBuilder where = |
998 |
|
new StringBuilder(", BaseObject as obj" + ", " + fieldTypeName + " as prop where doc.fullName=obj.name" |
999 |
|
+ " and (obj.className=? or obj.className=?)"); |
1000 |
0 |
parameterValues.add(rightClass.getName()); |
1001 |
0 |
parameterValues.add(globalRightClass.getName()); |
1002 |
|
|
1003 |
0 |
where.append(" and obj.id=prop.id.id"); |
1004 |
|
|
1005 |
0 |
where.append(" and prop.name=?"); |
1006 |
0 |
parameterValues.add(fieldName); |
1007 |
|
|
1008 |
0 |
where.append(" and prop.value like ?"); |
1009 |
|
|
1010 |
0 |
if (context.getWikiId() == null || context.getWikiId().equalsIgnoreCase(userOrGroupWiki)) { |
1011 |
0 |
if (userOrGroupSpace == null || userOrGroupSpace.equals(DEFAULT_USERORGROUP_SPACE)) { |
1012 |
0 |
parameterValues.add(HQLLIKE_ALL_SYMBOL + userOrGroupName + HQLLIKE_ALL_SYMBOL); |
1013 |
|
} else { |
1014 |
0 |
parameterValues.add(HQLLIKE_ALL_SYMBOL + userOrGroupSpace + SPACEPAGENAME_SEP + userOrGroupName |
1015 |
|
+ HQLLIKE_ALL_SYMBOL); |
1016 |
|
} |
1017 |
|
} else { |
1018 |
0 |
parameterValues.add(HQLLIKE_ALL_SYMBOL + userOrGroupWiki + WIKIFULLNAME_SEP + userOrGroupName |
1019 |
|
+ HQLLIKE_ALL_SYMBOL); |
1020 |
|
} |
1021 |
|
|
1022 |
0 |
List<XWikiDocument> documentList = |
1023 |
|
context.getWiki().getStore().searchDocuments(where.toString(), parameterValues, context); |
1024 |
|
|
1025 |
0 |
for (XWikiDocument groupDocument : documentList) { |
1026 |
0 |
if (removeUserOrGroupFromAllRights(groupDocument, userOrGroupWiki, userOrGroupSpace, userOrGroupName, user, |
1027 |
|
context)) { |
1028 |
0 |
context.getWiki().saveDocument(groupDocument, context); |
1029 |
|
} |
1030 |
|
} |
1031 |
|
} |
1032 |
|
|
1033 |
|
|
1034 |
|
|
1035 |
|
|
1036 |
|
@param |
1037 |
|
@param |
1038 |
|
@param |
1039 |
|
@param |
1040 |
|
@throws |
1041 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
1042 |
0 |
public void removeDirectRights(String spaceOrPage, List<String> levelNames, String comment, XWikiContext context)... |
1043 |
|
throws XWikiException |
1044 |
|
{ |
1045 |
0 |
XWikiDocument preferences = getXWikiPreferencesDoc(spaceOrPage, context); |
1046 |
|
|
1047 |
0 |
boolean global = isGlobal(preferences, spaceOrPage); |
1048 |
|
|
1049 |
0 |
EntityReference rightClassReference = |
1050 |
0 |
global ? XWikiRightServiceImpl.GLOBALRIGHTCLASS_REFERENCE : XWikiRightServiceImpl.RIGHTCLASS_REFERENCE; |
1051 |
|
|
1052 |
0 |
List<BaseObject> rightObjects = preferences.getXObjects(rightClassReference); |
1053 |
0 |
if (rightObjects != null && !rightObjects.isEmpty()) { |
1054 |
0 |
preferences.removeXObjects(rightClassReference); |
1055 |
0 |
context.getWiki().saveDocument(preferences, comment, context); |
1056 |
|
} |
1057 |
|
} |
1058 |
|
|
1059 |
|
|
1060 |
|
|
1061 |
|
|
1062 |
|
@param |
1063 |
|
@param |
1064 |
|
@param |
1065 |
|
@param |
1066 |
|
@return |
1067 |
|
@throws |
1068 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.4 |
|
1069 |
0 |
public boolean groupContainsMember(String groupName, String memberName,... |
1070 |
|
Map<String, Collection<String>> groupCacheIn, XWikiContext context) throws XWikiException |
1071 |
|
{ |
1072 |
0 |
boolean found = false; |
1073 |
|
|
1074 |
0 |
Map<String, Collection<String>> groupCache = groupCacheIn; |
1075 |
0 |
if (groupCache == null) { |
1076 |
0 |
groupCache = new HashMap<String, Collection<String>>(); |
1077 |
|
} |
1078 |
|
|
1079 |
0 |
Collection<String> memberList = groupCache.get(groupName); |
1080 |
|
|
1081 |
0 |
if (memberList == null) { |
1082 |
0 |
memberList = |
1083 |
|
context.getWiki().getGroupService(context).getAllMembersNamesForGroup(groupName, 0, 0, context); |
1084 |
0 |
groupCache.put(groupName, memberList); |
1085 |
|
} |
1086 |
|
|
1087 |
0 |
if (memberList.contains(memberName) |
1088 |
|
|| memberList.contains(context.getWikiId() + WIKIFULLNAME_SEP + memberName)) { |
1089 |
0 |
found = true; |
1090 |
|
} else { |
1091 |
0 |
for (String groupMemberName : memberList) { |
1092 |
0 |
if (groupContainsMember(groupMemberName, memberName, groupCache, context)) { |
1093 |
0 |
found = true; |
1094 |
0 |
break; |
1095 |
|
} |
1096 |
|
} |
1097 |
|
} |
1098 |
|
|
1099 |
0 |
return found; |
1100 |
|
} |
1101 |
|
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
|
@param |
1106 |
|
@param |
1107 |
|
@return |
1108 |
|
@throws |
1109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
1110 |
9 |
public Collection<DocumentReference> resolveUsers(DocumentReference userOrGroup, XWikiContext context)... |
1111 |
|
throws XWikiException |
1112 |
|
{ |
1113 |
9 |
Collection<DocumentReference> userReferences = new LinkedHashSet<>(); |
1114 |
9 |
Iterator<DocumentReference> iterator = |
1115 |
|
new ReferenceUserIterator(userOrGroup, this.explicitDocumentReferenceResolver, context); |
1116 |
17 |
while (iterator.hasNext()) { |
1117 |
8 |
userReferences.add(iterator.next()); |
1118 |
|
} |
1119 |
9 |
return userReferences; |
1120 |
|
} |
1121 |
|
|
1122 |
|
|
1123 |
|
|
1124 |
|
|
1125 |
|
@param |
1126 |
|
@param |
1127 |
|
@return |
1128 |
|
@throws |
1129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1130 |
9 |
public Collection<DocumentReference> resolveUsers(String userOrGroup, XWikiContext context) throws XWikiException... |
1131 |
|
{ |
1132 |
9 |
return resolveUsers(this.currentDocumentReferenceResolver.resolve(userOrGroup), context); |
1133 |
|
} |
1134 |
|
|
1135 |
|
|
1136 |
|
|
1137 |
|
|
1138 |
|
@param |
1139 |
|
@param |
1140 |
|
@return |
1141 |
|
@throws |
1142 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
1143 |
7 |
public Collection<DocumentReference> resolveUsers(List<String> referenceList, XWikiContext context)... |
1144 |
|
throws XWikiException |
1145 |
|
{ |
1146 |
7 |
Collection<DocumentReference> users = new LinkedHashSet<>(); |
1147 |
|
|
1148 |
7 |
for (String reference : referenceList) { |
1149 |
9 |
users.addAll(resolveUsers(reference, context)); |
1150 |
|
} |
1151 |
|
|
1152 |
7 |
return users; |
1153 |
|
} |
1154 |
|
} |