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