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.app.subapp.sitemapdetail.contentviews.formatter; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeTypes; |
37 |
|
import info.magnolia.jcr.util.NodeUtil; |
38 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrNodeAdapter; |
39 |
|
import info.magnolia.ui.workbench.column.AbstractColumnFormatter; |
40 |
|
import info.magnolia.ui.workbench.column.definition.PropertyColumnDefinition; |
41 |
|
import info.magnolia.util.EscapeUtil; |
42 |
|
|
43 |
|
import javax.inject.Inject; |
44 |
|
import javax.jcr.Node; |
45 |
|
import javax.jcr.RepositoryException; |
46 |
|
|
47 |
|
import org.slf4j.Logger; |
48 |
|
import org.slf4j.LoggerFactory; |
49 |
|
|
50 |
|
import com.vaadin.data.Item; |
51 |
|
import com.vaadin.ui.Table; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 7 |
Complexity Density: 0.5 |
|
57 |
|
public class FolderNameColumnFormatter extends AbstractColumnFormatter<PropertyColumnDefinition> { |
58 |
|
|
59 |
|
private Logger log = LoggerFactory.getLogger(getClass()); |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
5 |
@Inject... |
62 |
|
public FolderNameColumnFormatter(PropertyColumnDefinition definition) { |
63 |
5 |
super(definition); |
64 |
|
} |
65 |
|
|
|
|
| 84.2% |
Uncovered Elements: 3 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
66 |
5 |
@Override... |
67 |
|
public Object generateCell(Table source, Object itemId, Object columnId) { |
68 |
5 |
Item item = source.getItem(itemId); |
69 |
5 |
if (item instanceof JcrNodeAdapter) { |
70 |
1 |
JcrNodeAdapter nodeAdapter = (JcrNodeAdapter)item; |
71 |
1 |
Node node = nodeAdapter.getJcrItem(); |
72 |
1 |
try { |
73 |
1 |
if (NodeUtil.isNodeType(node, NodeTypes.Folder.NAME)) { |
74 |
1 |
return node.getName(); |
75 |
|
} |
76 |
|
} catch (RepositoryException e) { |
77 |
0 |
log.error("Failed to determine folder name: ", e); |
78 |
0 |
return ""; |
79 |
|
} |
80 |
|
} |
81 |
4 |
if (item != null && item.getItemProperty(columnId) != null) { |
82 |
2 |
String sitemapName = item.getItemProperty(columnId).getValue().toString(); |
83 |
2 |
return EscapeUtil.escapeXss(sitemapName); |
84 |
|
} |
85 |
2 |
return ""; |
86 |
|
} |
87 |
|
} |