1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.user.internal.group

File GroupsCache.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
12
3
1
80
34
5
0.42
4
3
1.67

Classes

Class Line # Actions
GroupsCache 37 12 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 9 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.user.internal.group;
21   
22    import java.util.Collection;
23   
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.model.reference.DocumentReference;
28   
29    /**
30    * Manipulate the cache of entity's groups.
31    *
32    * @version $Id: dbe5e368d893aa66386abb37c2bc1db5168cb309 $
33    * @since 10.8RC1
34    */
35    @Component(roles = GroupsCache.class)
36    @Singleton
 
37    public class GroupsCache extends AbstractGroupCache
38    {
39    /**
40    * Set the id.
41    */
 
42  27 toggle public GroupsCache()
43    {
44  27 super("user.membership.groups");
45    }
46   
 
47  479 toggle private String toKey(DocumentReference reference, Collection<String> wikis)
48    {
49  479 StringBuilder builder = new StringBuilder();
50   
51  479 if (wikis != null) {
52  140 for (String wiki : wikis) {
53  217 if (builder.length() > 0) {
54  77 builder.append('_');
55    }
56  217 builder.append(wiki);
57    }
58    }
59   
60  479 builder.append('_');
61   
62  479 builder.append(this.serializer.serialize(reference));
63   
64  479 return builder.toString();
65    }
66   
67    /**
68    * @param reference the reference of the entity for which to get the cache entry
69    * @param wikis the wikis where the values are located
70    * @param create true if an entry should be created if none exist
71    * @return the cache entry
72    */
 
73  479 toggle public GroupCacheEntry getCacheEntry(DocumentReference reference, Collection<String> wikis, boolean create)
74    {
75  479 String key = toKey(reference, wikis);
76   
77  479 return getCacheEntry(key, reference, create);
78    }
79   
80    }