1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.commands; |
35 |
|
|
36 |
|
import info.magnolia.commands.MgnlCommand; |
37 |
|
import info.magnolia.context.Context; |
38 |
|
import info.magnolia.module.cache.Cache; |
39 |
|
import info.magnolia.module.cache.CacheFactory; |
40 |
|
import info.magnolia.module.cache.inject.CacheFactoryProvider; |
41 |
|
import info.magnolia.objectfactory.Components; |
42 |
|
|
43 |
|
import javax.inject.Inject; |
44 |
|
|
45 |
|
import org.apache.commons.lang3.StringUtils; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.55 |
|
50 |
|
public class FlushNamedCacheCommand extends MgnlCommand { |
51 |
|
|
52 |
|
public static final String CACHE_NAME = "cacheName"; |
53 |
|
|
54 |
|
private final CacheFactoryProvider cacheFactoryProvider; |
55 |
|
private String cacheName; |
56 |
|
|
57 |
|
|
58 |
|
@deprecated@link |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0 |
@Deprecated... |
61 |
|
public FlushNamedCacheCommand() { |
62 |
0 |
this(Components.getComponent(CacheFactoryProvider.class)); |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
@Inject... |
66 |
|
public FlushNamedCacheCommand(CacheFactoryProvider cacheFactoryProvider) { |
67 |
0 |
this.cacheFactoryProvider = cacheFactoryProvider; |
68 |
|
} |
69 |
|
|
70 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
71 |
0 |
@Override... |
72 |
|
public boolean execute(Context context) throws Exception { |
73 |
0 |
String cacheName = (String) context.get(CACHE_NAME); |
74 |
0 |
if (StringUtils.isBlank(cacheName)) { |
75 |
0 |
cacheName = getCacheName(); |
76 |
|
} |
77 |
0 |
if(StringUtils.isNotBlank(cacheName)) { |
78 |
0 |
CacheFactory factory = cacheFactoryProvider.get(); |
79 |
0 |
Cache cache = factory.getCache(cacheName); |
80 |
0 |
if(cache != null) { |
81 |
0 |
cache.clear(); |
82 |
|
} |
83 |
|
} |
84 |
0 |
return true; |
85 |
|
} |
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
87 |
|
public String getCacheName() {... |
88 |
|
return cacheName; |
89 |
|
} |
90 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
91 |
|
public void setCacheName(String cacheName) {... |
92 |
|
this.cacheName = cacheName; |
93 |
|
} |
94 |
|
} |