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.googlesitemap.model; |
35 |
|
|
36 |
|
import info.magnolia.context.MgnlContext; |
37 |
|
import info.magnolia.module.googlesitemap.bean.SiteMapEntry; |
38 |
|
import info.magnolia.module.googlesitemap.service.SiteMapService; |
39 |
|
import info.magnolia.module.googlesitemap.service.SiteMapXMLUtil; |
40 |
|
import info.magnolia.rendering.model.RenderingModel; |
41 |
|
import info.magnolia.rendering.model.RenderingModelImpl; |
42 |
|
import info.magnolia.rendering.template.RenderableDefinition; |
43 |
|
|
44 |
|
import java.util.Collections; |
45 |
|
import java.util.Iterator; |
46 |
|
|
47 |
|
import javax.inject.Inject; |
48 |
|
import javax.jcr.Node; |
49 |
|
import javax.jcr.RepositoryException; |
50 |
|
import javax.xml.bind.JAXBException; |
51 |
|
|
52 |
|
import org.slf4j.Logger; |
53 |
|
import org.slf4j.LoggerFactory; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@param |
58 |
|
|
|
|
| 47.6% |
Uncovered Elements: 11 (21) |
Complexity: 9 |
Complexity Density: 0.6 |
|
59 |
|
public class SiteMapModel<RD extends RenderableDefinition> extends RenderingModelImpl<RD> { |
60 |
|
|
61 |
|
|
62 |
|
private static final Logger log = LoggerFactory.getLogger(SiteMapModel.class); |
63 |
|
|
64 |
|
|
65 |
|
protected SiteMapService siteMapService; |
66 |
|
|
67 |
|
private SiteMapXMLUtil xmlUtil; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
72 |
2
|
@Inject... |
73 |
|
public SiteMapModel(Node content, RD definition, RenderingModel<?> parent, SiteMapService siteMapService, SiteMapXMLUtil xmlUtil) { |
74 |
2
|
super(content, definition, parent); |
75 |
2
|
this.siteMapService = siteMapService; |
76 |
2
|
this.xmlUtil = xmlUtil; |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
79 |
0
|
@Override... |
80 |
|
public String execute() { |
81 |
|
|
82 |
|
|
83 |
0
|
if (this.definition.getParameters() != null && this.definition.getParameters().containsKey("xmlDisplay")) { |
84 |
0
|
MgnlContext.getWebContext().getResponse().setContentType("text/xml"); |
85 |
|
} |
86 |
|
|
87 |
0
|
return null; |
88 |
|
} |
89 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
90 |
1
|
public Iterator<SiteMapEntry> getSiteMapBeans() {... |
91 |
1
|
try { |
92 |
1
|
return siteMapService.getSiteMapBeans(this.content); |
93 |
|
} catch (RepositoryException e) { |
94 |
0
|
log.error("Could not initialize SiteMapBeans", e); |
95 |
0
|
return Collections.<SiteMapEntry>emptySet().iterator(); |
96 |
|
} |
97 |
|
} |
98 |
|
|
|
|
| 40% |
Uncovered Elements: 3 (5) |
Complexity: 3 |
Complexity Density: 0.6 |
|
99 |
1
|
public String getXML() {... |
100 |
1
|
try { |
101 |
1
|
return xmlUtil.generateSiteMapXML(this.content); |
102 |
|
} catch (RepositoryException e) { |
103 |
0
|
log.error("Repository operation problem occurred while generating XML:", e); |
104 |
|
} catch (JAXBException e) { |
105 |
0
|
log.error("JAXB operation problem occurred while generating XML:", e); |
106 |
|
} |
107 |
0
|
return ""; |
108 |
|
} |
109 |
|
} |