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.blossom.urimapping; |
35 |
|
|
36 |
|
import java.util.Iterator; |
37 |
|
import java.util.concurrent.CopyOnWriteArrayList; |
38 |
|
|
39 |
|
import info.magnolia.cms.beans.config.VirtualURIMapping; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@since |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 7 |
Complexity Density: 0.54 |
|
47 |
|
public class BlossomVirtualURIMapping implements VirtualURIMapping { |
48 |
|
|
49 |
|
private static final CopyOnWriteArrayList<VirtualURIMapping> mappings = new CopyOnWriteArrayList<VirtualURIMapping>(); |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
6 |
public static void addMapping(VirtualURIMapping mapping) {... |
52 |
6 |
mappings.add(mapping); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
55 |
15 |
@Override... |
56 |
|
public MappingResult mapURI(String uri) { |
57 |
15 |
if (mappings.isEmpty()) { |
58 |
4 |
return null; |
59 |
|
} |
60 |
11 |
int highestLevel = 0; |
61 |
11 |
MappingResult bestResult = null; |
62 |
49 |
for (Iterator<VirtualURIMapping> iterator = mappings.iterator(); iterator.hasNext(); ) { |
63 |
38 |
VirtualURIMapping adapter = iterator.next(); |
64 |
38 |
MappingResult result = adapter.mapURI(uri); |
65 |
38 |
if (result != null && highestLevel < result.getLevel()) { |
66 |
6 |
bestResult = result; |
67 |
6 |
highestLevel = result.getLevel(); |
68 |
|
} |
69 |
|
} |
70 |
11 |
return bestResult; |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
2 |
public void clear() {... |
74 |
2 |
mappings.clear(); |
75 |
|
} |
76 |
|
} |