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.jcr.wrapper;
35
36 import info.magnolia.cms.i18n.I18nContentSupport;
37 import info.magnolia.cms.i18n.I18nContentSupportFactory;
38 import info.magnolia.cms.util.ContentUtil;
39
40 import javax.jcr.AccessDeniedException;
41 import javax.jcr.ItemNotFoundException;
42 import javax.jcr.Node;
43 import javax.jcr.PathNotFoundException;
44 import javax.jcr.Property;
45 import javax.jcr.RepositoryException;
46
47
48
49
50
51
52
53 public class I18nNodeWrapper extends ChildWrappingNodeWrapper {
54
55 public I18nNodeWrapper(Node wrapped) {
56 super(wrapped);
57 }
58
59 @Override
60 public boolean hasProperty(String relPath) throws RepositoryException {
61 final I18nContentSupport i18nSupport = I18nContentSupportFactory.getI18nSupport();
62 return i18nSupport.getNodeData(ContentUtil.asContent(getWrappedNode()), relPath).isExist();
63 }
64
65 @Override
66 public Node wrapNode(Node node) {
67 if (node == null) {
68 return null;
69 }
70 return new I18nNodeWrapper(node);
71 }
72
73 @Override
74 public Property getProperty(String relPath) throws PathNotFoundException, RepositoryException {
75 final I18nContentSupport i18nSupport = I18nContentSupportFactory.getI18nSupport();
76 return i18nSupport.getNodeData(ContentUtil.asContent(getWrappedNode()), relPath).getJCRProperty();
77 }
78
79 @Override
80 public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
81 final I18nContentSupport i18nSupport = I18nContentSupportFactory.getI18nSupport();
82 return wrapNode(i18nSupport.getNode(getWrappedNode(), relPath));
83 }
84
85 @Override
86 public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
87 return wrapNode(super.getParent());
88 }
89 }