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.render; |
35 |
|
|
36 |
|
import java.io.IOException; |
37 |
|
import java.util.Map; |
38 |
|
import javax.servlet.ServletException; |
39 |
|
import javax.servlet.http.HttpServletRequest; |
40 |
|
import javax.servlet.http.HttpServletResponse; |
41 |
|
|
42 |
|
import info.magnolia.cms.util.ServletUtil; |
43 |
|
import info.magnolia.context.MgnlContext; |
44 |
|
import info.magnolia.context.WebContext; |
45 |
|
import info.magnolia.module.blossom.template.BlossomRenderable; |
46 |
|
import info.magnolia.rendering.context.RenderingContext; |
47 |
|
import info.magnolia.rendering.engine.RenderException; |
48 |
|
import info.magnolia.rendering.renderer.Renderer; |
49 |
|
|
50 |
|
|
51 |
|
@link |
52 |
|
|
53 |
|
@since |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.4 |
|
55 |
|
public class BlossomTemplateRenderer implements Renderer { |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.4 |
|
57 |
0 |
@Override... |
58 |
|
public void render(RenderingContext ctx, Map<String, Object> contextObjects) throws RenderException { |
59 |
|
|
60 |
0 |
try { |
61 |
|
|
62 |
0 |
BlossomRenderable renderable = (BlossomRenderable) ctx.getRenderableDefinition(); |
63 |
|
|
64 |
0 |
RenderContext context = RenderContext.push(); |
65 |
0 |
try { |
66 |
|
|
67 |
0 |
context.setRenderingContext(ctx); |
68 |
0 |
context.setContextObjects(contextObjects); |
69 |
|
|
70 |
0 |
WebContext webContext = MgnlContext.getWebContext(); |
71 |
0 |
HttpServletRequest request = webContext.getRequest(); |
72 |
0 |
HttpServletResponse response = webContext.getResponse(); |
73 |
|
|
74 |
|
|
75 |
0 |
if (response.isCommitted() || (ServletUtil.isForward(request) || ServletUtil.isInclude(request))) { |
76 |
0 |
renderable.getDispatcher().include(renderable.getHandlerPath(), request, response); |
77 |
|
} else { |
78 |
0 |
renderable.getDispatcher().forward(renderable.getHandlerPath(), request, response); |
79 |
|
} |
80 |
|
|
81 |
|
} finally { |
82 |
0 |
RenderContext.pop(); |
83 |
|
} |
84 |
|
|
85 |
|
} catch (ServletException e) { |
86 |
0 |
throw new RenderException(e); |
87 |
|
} catch (IOException e) { |
88 |
0 |
throw new RenderException(e); |
89 |
|
} |
90 |
|
} |
91 |
|
} |