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.decoration;
35
36 import javax.jcr.AccessDeniedException;
37 import javax.jcr.ItemNotFoundException;
38 import javax.jcr.Node;
39 import javax.jcr.Property;
40 import javax.jcr.RepositoryException;
41 import javax.jcr.Session;
42 import javax.jcr.ValueFormatException;
43
44 import info.magnolia.jcr.wrapper.DelegatePropertyWrapper;
45
46
47
48
49
50
51 public class ContentDecoratorPropertyWrapper extends DelegatePropertyWrapper {
52
53 private final ContentDecorator contentDecorator;
54
55 public ContentDecoratorPropertyWrapper(Property property, ContentDecorator contentDecorator) {
56 super(property);
57 this.contentDecorator = contentDecorator;
58 }
59
60 @Override
61 public Session getSession() throws RepositoryException {
62 return wrapSession(super.getSession());
63 }
64
65 @Override
66 public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
67 return wrapNode(super.getParent());
68 }
69
70 @Override
71 public Node getNode() throws ItemNotFoundException, ValueFormatException, RepositoryException {
72 Node node = super.getNode();
73 if (!contentDecorator.evaluateNode(node)) {
74 throw new ItemNotFoundException();
75 }
76 return wrapNode(node);
77 }
78
79 @Override
80 public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
81 Property property = super.getProperty();
82 if (!contentDecorator.evaluateProperty(property)) {
83 throw new ItemNotFoundException();
84 }
85 return wrapProperty(property);
86 }
87
88 protected Session wrapSession(Session session) {
89 return contentDecorator.wrapSession(session);
90 }
91
92 protected Node wrapNode(Node node) {
93 return contentDecorator.wrapNode(node);
94 }
95
96 protected Property wrapProperty(Property property) {
97 return contentDecorator.wrapProperty(property);
98 }
99 }