1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.lesscss.internal.cache; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.lesscss.internal.colortheme.ColorThemeReference; |
27 |
|
import org.xwiki.lesscss.internal.skin.SkinReference; |
28 |
|
import org.xwiki.lesscss.resources.LESSResourceReference; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@since |
34 |
|
@version |
35 |
|
|
36 |
|
@Component(roles = CacheKeyFactory.class) |
37 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.25 |
|
38 |
|
public class CacheKeyFactory |
39 |
|
{ |
40 |
|
private static final String CACHE_KEY_SEPARATOR = "_"; |
41 |
|
|
42 |
|
@Inject |
43 |
|
private XWikiContextCacheKeyFactory xcontextCacheKeyFactory; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
@param |
50 |
|
@param |
51 |
|
@param |
52 |
|
|
53 |
|
@return |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
55 |
4397 |
public String getCacheKey(LESSResourceReference lessResourceReference, SkinReference skinReference,... |
56 |
|
ColorThemeReference colorThemeReference, boolean withContext) |
57 |
|
{ |
58 |
4397 |
String lessResource = lessResourceReference.serialize(); |
59 |
4396 |
String skin = skinReference.serialize(); |
60 |
4397 |
String colorTheme = colorThemeReference.serialize(); |
61 |
|
|
62 |
4397 |
String result = lessResource.length() + CACHE_KEY_SEPARATOR + lessResource + CACHE_KEY_SEPARATOR |
63 |
|
+ skin.length() + CACHE_KEY_SEPARATOR + skin + CACHE_KEY_SEPARATOR |
64 |
|
+ colorTheme.length() + CACHE_KEY_SEPARATOR + colorTheme; |
65 |
|
|
66 |
4397 |
if (withContext) { |
67 |
204 |
String xcontext = xcontextCacheKeyFactory.getCacheKey(); |
68 |
204 |
result += CACHE_KEY_SEPARATOR + xcontext.length() + CACHE_KEY_SEPARATOR + xcontext; |
69 |
|
} |
70 |
|
|
71 |
4397 |
return result; |
72 |
|
} |
73 |
|
} |