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.cms.util;
35
36 import info.magnolia.cms.core.Content;
37 import info.magnolia.cms.core.HierarchyManager;
38 import info.magnolia.cms.core.ItemType;
39 import info.magnolia.cms.core.NodeData;
40 import info.magnolia.cms.core.search.QueryManager;
41 import info.magnolia.cms.security.AccessDeniedException;
42 import info.magnolia.cms.security.AccessManager;
43
44 import javax.jcr.RepositoryException;
45 import javax.jcr.Workspace;
46
47
48
49
50
51
52 public abstract class HierarchyManagerWrapper implements HierarchyManager {
53
54 private final HierarchyManager wrappedHM;
55
56 protected HierarchyManagerWrapper(HierarchyManager wrappedHM) {
57 this.wrappedHM = wrappedHM;
58 }
59
60 public HierarchyManager getWrappedHierarchyManager() {
61 return wrappedHM;
62 }
63
64
65
66
67 @Deprecated
68 public HierarchyManager getDelegate() {
69 return wrappedHM;
70 }
71
72 public String toString() {
73 final StringBuilder buffer = new StringBuilder();
74 buffer.append(getClass().getSimpleName());
75 buffer.append(" for ");
76 buffer.append(getWrappedHierarchyManager().toString());
77 return buffer.toString();
78 }
79
80
81
82
83
84
85
86 protected Content wrap(Content content) {
87 return content;
88 }
89
90
91
92
93
94
95 protected NodeData wrap(NodeData nodeData) {
96 return nodeData;
97 }
98
99
100
101
102
103
104 protected String transformPath(String path) {
105 return path;
106 }
107
108
109 public AccessManager getAccessManager() {
110 return getWrappedHierarchyManager().getAccessManager();
111 }
112
113 public QueryManager getQueryManager() {
114 return getWrappedHierarchyManager().getQueryManager();
115 }
116
117 public Content createContent(String path, String label, String contentType) throws RepositoryException {
118 path = transformPath(path);
119 return wrap(getWrappedHierarchyManager().createContent(path, label, contentType));
120 }
121
122 public Content getContent(String path) throws RepositoryException {
123 path = transformPath(path);
124 return wrap(getWrappedHierarchyManager().getContent(path));
125 }
126
127 public Content getContent(String path, boolean create, ItemType type) throws RepositoryException {
128 path = transformPath(path);
129 return wrap(getWrappedHierarchyManager().getContent(path, create, type));
130 }
131
132 public NodeData getNodeData(String path) throws RepositoryException {
133 path = transformPath(path);
134 return wrap(getWrappedHierarchyManager().getNodeData(path));
135 }
136
137
138
139
140 @Deprecated
141 public Content getPage(String path, String templateName) throws RepositoryException {
142 path = transformPath(path);
143 return wrap(getWrappedHierarchyManager().getPage(path, templateName));
144 }
145
146 public void delete(String path) throws RepositoryException {
147 path = transformPath(path);
148 getWrappedHierarchyManager().delete(path);
149 }
150
151 public Content getRoot() throws RepositoryException {
152 return wrap(getWrappedHierarchyManager().getRoot());
153 }
154
155
156
157
158 @Deprecated
159 public boolean isPage(String path) throws AccessDeniedException {
160 path = transformPath(path);
161 return getWrappedHierarchyManager().isPage(path);
162 }
163
164 public boolean isExist(String path) {
165 path = transformPath(path);
166 return getWrappedHierarchyManager().isExist(path);
167 }
168
169 public boolean isGranted(String path, long permissions) {
170 path = transformPath(path);
171 return getWrappedHierarchyManager().isGranted(path, permissions);
172 }
173
174
175
176
177 @Deprecated
178 public boolean isNodeType(String path, String type) {
179 path = transformPath(path);
180 return getWrappedHierarchyManager().isNodeType(path, type);
181 }
182
183
184
185
186 @Deprecated
187 public boolean isNodeType(String path, ItemType type) {
188 path = transformPath(path);
189 return getWrappedHierarchyManager().isNodeType(path, type);
190 }
191
192 public boolean isNodeData(String path) throws AccessDeniedException {
193 path = transformPath(path);
194 return getWrappedHierarchyManager().isNodeData(path);
195 }
196
197 public Content getContentByUUID(String uuid) throws RepositoryException {
198 return wrap(getWrappedHierarchyManager().getContentByUUID(uuid));
199 }
200
201 public Workspace getWorkspace() {
202 return getWrappedHierarchyManager().getWorkspace();
203 }
204
205 public void moveTo(String source, String destination) throws RepositoryException {
206 source = transformPath(source);
207 destination = transformPath(destination);
208 getWrappedHierarchyManager().moveTo(source, destination);
209 }
210
211 public void copyTo(String source, String destination) throws RepositoryException {
212 source = transformPath(source);
213 destination = transformPath(destination);
214 getWrappedHierarchyManager().copyTo(source, destination);
215 }
216
217 public void save() throws RepositoryException {
218 getWrappedHierarchyManager().save();
219 }
220
221 public boolean hasPendingChanges() throws RepositoryException {
222 return getWrappedHierarchyManager().hasPendingChanges();
223 }
224
225 public void refresh(boolean keepChanges) throws RepositoryException {
226 getWrappedHierarchyManager().refresh(keepChanges);
227 }
228
229 public String getName() {
230 return getWrappedHierarchyManager().getName();
231 }
232 }