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.setup; |
35 |
|
|
36 |
|
import info.magnolia.module.InstallContext; |
37 |
|
import info.magnolia.module.delta.AbstractRepositoryTask; |
38 |
|
import info.magnolia.module.delta.TaskExecutionException; |
39 |
|
import info.magnolia.repository.RepositoryConstants; |
40 |
|
|
41 |
|
import javax.jcr.Node; |
42 |
|
import javax.jcr.PathNotFoundException; |
43 |
|
import javax.jcr.RepositoryException; |
44 |
|
import javax.jcr.Session; |
45 |
|
|
46 |
|
|
47 |
|
@value |
48 |
|
|
|
|
| 94.7% |
Uncovered Elements: 1 (19) |
Complexity: 8 |
Complexity Density: 0.67 |
|
49 |
|
class RemoveVirtualUriMappingTask extends AbstractRepositoryTask { |
50 |
|
private static final String VIRTUAL_URI_PATH = "/modules/cache/virtualURIMapping/tildeCacheRessources"; |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
11 |
RemoveVirtualUriMappingTask() {... |
53 |
11 |
super("Remove unnecessary virtual URI mapping", "Removes the now-unnecessary virtual URI mapping for resources ~far~future~cache."); |
54 |
|
} |
55 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 6 |
Complexity Density: 0.6 |
|
56 |
7 |
@Override... |
57 |
|
protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException { |
58 |
7 |
final Session session = ctx.getJCRSession(RepositoryConstants.CONFIG); |
59 |
7 |
try { |
60 |
7 |
final Node n = session.getNode(VIRTUAL_URI_PATH); |
61 |
4 |
final Node parent = n.getParent(); |
62 |
4 |
if (checkProperty(n, "class", "info.magnolia.cms.beans.config.RegexpVirtualURIMapping") && |
63 |
|
checkProperty(n, "fromURI", "(\\.*)\\.(\\d{4}-(?:\\d{2}-){5}\\d{3})\\.cache\\.(css|js)") && |
64 |
|
checkProperty(n, "toURI", "$1~$2~cache.$3")) { |
65 |
3 |
n.remove(); |
66 |
3 |
if (!parent.hasNodes()) { |
67 |
3 |
parent.remove(); |
68 |
|
} |
69 |
|
} else { |
70 |
1 |
ctx.warn("Virtual URI mapping found at " + VIRTUAL_URI_PATH + " with different values than expected. Make sure you rename or remove it appropriately."); |
71 |
|
} |
72 |
|
} catch (PathNotFoundException e) { |
73 |
3 |
ctx.warn("Virtual URI mapping not found at " + VIRTUAL_URI_PATH + ". If you modified or moved it, make sure you remove it appropriately."); |
74 |
|
} |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
11 |
private boolean checkProperty(Node n, String name, String expectedValue) throws RepositoryException {... |
78 |
11 |
return n.getProperty(name).getString().equals(expectedValue); |
79 |
|
} |
80 |
|
} |