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.templating.renderers; |
35 |
|
|
36 |
|
import info.magnolia.module.templating.RenderableDefinition; |
37 |
|
import info.magnolia.cms.core.Content; |
38 |
|
import info.magnolia.cms.util.NodeMapWrapper; |
39 |
|
import info.magnolia.context.MgnlContext; |
40 |
|
import info.magnolia.context.WebContext; |
41 |
|
import info.magnolia.module.templating.RenderException; |
42 |
|
|
43 |
|
import javax.servlet.http.HttpServletRequest; |
44 |
|
import javax.servlet.http.HttpServletResponse; |
45 |
|
|
46 |
|
import java.io.Writer; |
47 |
|
import java.util.Map; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@author |
54 |
|
@version |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
56 |
|
public class JspTemplateRenderer extends AbstractTemplateRenderer { |
57 |
|
|
58 |
|
private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(JspTemplateRenderer.class); |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
60 |
0
|
protected void onRender(Content content, RenderableDefinition definition, Writer out, Map ctx, String templatePath) throws RenderException {... |
61 |
0
|
HttpServletRequest request = ((WebContext) MgnlContext.getInstance()).getRequest(); |
62 |
0
|
HttpServletResponse response = ((WebContext) MgnlContext.getInstance()).getResponse(); |
63 |
0
|
if (response.isCommitted()) { |
64 |
0
|
log.warn("Attempting to forward to {}, but response is already committed.", templatePath); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
0
|
try { |
69 |
0
|
request.getRequestDispatcher(templatePath).forward(request, response); |
70 |
|
} |
71 |
|
catch (Exception e) { |
72 |
0
|
throw new RenderException("Can't render template " + templatePath, e); |
73 |
|
} |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
0
|
protected Content wrapNodeForTemplate(Content currentContent, Content mainContent) {... |
80 |
0
|
final Content wrapped = super.wrapNodeForTemplate(currentContent, mainContent); |
81 |
0
|
return new NodeMapWrapper(wrapped, mainContent.getHandle()); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0
|
protected Map newContext() {... |
85 |
0
|
return MgnlContext.getWebContext("JspTemplateRenderer can only be used with a WebContext"); |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0
|
protected String getPageAttributeName() {... |
89 |
0
|
return "actpage"; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
} |