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.preexecution; |
35 |
|
|
36 |
|
import javax.servlet.http.HttpServletRequest; |
37 |
|
|
38 |
|
import org.springframework.beans.BeansException; |
39 |
|
import org.springframework.beans.factory.InitializingBean; |
40 |
|
import org.springframework.context.ApplicationContext; |
41 |
|
import org.springframework.context.ApplicationContextAware; |
42 |
|
import org.springframework.core.Ordered; |
43 |
|
import org.springframework.web.servlet.HandlerExecutionChain; |
44 |
|
import org.springframework.web.servlet.HandlerMapping; |
45 |
|
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping; |
46 |
|
import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping; |
47 |
|
|
48 |
|
import info.magnolia.context.MgnlContext; |
49 |
|
import info.magnolia.module.blossom.dispatcher.BlossomDispatcher; |
50 |
|
import info.magnolia.module.blossom.dispatcher.BlossomDispatcherAware; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@since |
57 |
|
|
|
|
| 14.3% |
Uncovered Elements: 36 (42) |
Complexity: 10 |
Complexity Density: 0.4 |
|
58 |
|
public class BlossomHandlerMapping implements HandlerMapping, InitializingBean, ApplicationContextAware, BlossomDispatcherAware, Ordered { |
59 |
|
|
60 |
|
private ApplicationContext applicationContext; |
61 |
|
private HandlerMapping[] targetHandlerMappings; |
62 |
|
private DirectRenderingVoter directRenderingVoter; |
63 |
|
private BlossomDispatcher dispatcher; |
64 |
|
private int order = Integer.MAX_VALUE; |
65 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
66 |
|
@Override... |
67 |
|
public int getOrder() { |
68 |
|
return order; |
69 |
|
} |
70 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
71 |
|
public void setOrder(int order) {... |
72 |
|
this.order = order; |
73 |
|
} |
74 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
75 |
|
public HandlerMapping[] getTargetHandlerMappings() {... |
76 |
|
return targetHandlerMappings; |
77 |
|
} |
78 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
79 |
|
public void setTargetHandlerMapping(HandlerMapping targetHandlerMapping) {... |
80 |
|
this.targetHandlerMappings = new HandlerMapping[]{targetHandlerMapping}; |
81 |
|
} |
82 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
83 |
|
public void setTargetHandlerMappings(HandlerMapping[] targetHandlerMappings) {... |
84 |
|
this.targetHandlerMappings = targetHandlerMappings; |
85 |
|
} |
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
87 |
|
public DirectRenderingVoter getDirectRenderingPolicy() {... |
88 |
|
return directRenderingVoter; |
89 |
|
} |
90 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
91 |
|
public void setDirectRenderingPolicy(DirectRenderingVoter directRenderingVoter) {... |
92 |
|
this.directRenderingVoter = directRenderingVoter; |
93 |
|
} |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
95 |
0 |
@Override... |
96 |
|
public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception { |
97 |
|
|
98 |
0 |
PreexecutionContext preexecutionContext = PreexecutionContextHolder.get(request); |
99 |
|
|
100 |
|
|
101 |
0 |
if (preexecutionContext == null) { |
102 |
0 |
return getTargetHandler(request); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
0 |
String localUuid = MgnlContext.getAggregationState().getCurrentContentNode().getIdentifier(); |
107 |
0 |
if (!preexecutionContext.getUuid().equals(localUuid)) { |
108 |
0 |
return getTargetHandler(request); |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
0 |
if (preexecutionContext.isModelAndViewSet()) { |
113 |
0 |
return new HandlerExecutionChain(new ModelAndViewReuseController(preexecutionContext)); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
0 |
HandlerExecutionChain executionChain = getTargetHandler(request); |
120 |
0 |
if (executionChain == null) { |
121 |
0 |
return null; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
0 |
return new HandlerExecutionChain(new ModelAndViewGrabbingController(preexecutionContext, executionChain, directRenderingVoter, dispatcher)); |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
128 |
0 |
private HandlerExecutionChain getTargetHandler(HttpServletRequest request) throws Exception {... |
129 |
0 |
for (HandlerMapping targetHandlerMapping : targetHandlerMappings) { |
130 |
0 |
HandlerExecutionChain executionChain = targetHandlerMapping.getHandler(request); |
131 |
0 |
if (executionChain != null) { |
132 |
0 |
return executionChain; |
133 |
|
} |
134 |
|
} |
135 |
0 |
return null; |
136 |
|
} |
137 |
|
|
|
|
| 41.7% |
Uncovered Elements: 7 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
138 |
4 |
@Override... |
139 |
|
public void afterPropertiesSet() throws Exception { |
140 |
|
|
141 |
4 |
if (directRenderingVoter == null) { |
142 |
4 |
directRenderingVoter = new DefaultDirectRenderingVoter(); |
143 |
|
} |
144 |
|
|
145 |
4 |
if (targetHandlerMappings == null) { |
146 |
0 |
this.targetHandlerMappings = new HandlerMapping[2]; |
147 |
0 |
this.targetHandlerMappings[0] = applicationContext.getAutowireCapableBeanFactory().createBean(BeanNameUrlHandlerMapping.class); |
148 |
0 |
DefaultAnnotationHandlerMapping defaultAnnotationHandlerMapping = applicationContext.getAutowireCapableBeanFactory().createBean(DefaultAnnotationHandlerMapping.class); |
149 |
0 |
defaultAnnotationHandlerMapping.setUseDefaultSuffixPattern(false); |
150 |
0 |
this.targetHandlerMappings[1] = defaultAnnotationHandlerMapping; |
151 |
|
} |
152 |
|
} |
153 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
154 |
|
@Override... |
155 |
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
156 |
|
this.applicationContext = applicationContext; |
157 |
|
} |
158 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
159 |
|
@Override... |
160 |
|
public void setBlossomDispatcher(BlossomDispatcher dispatcher) { |
161 |
|
this.dispatcher = dispatcher; |
162 |
|
} |
163 |
|
} |