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.rest.delivery.jcr.decorator; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeUtil; |
37 |
|
|
38 |
|
import java.math.BigDecimal; |
39 |
|
import java.util.List; |
40 |
|
import java.util.stream.Collectors; |
41 |
|
|
42 |
|
import javax.jcr.Binary; |
43 |
|
import javax.jcr.Item; |
44 |
|
import javax.jcr.ItemVisitor; |
45 |
|
import javax.jcr.Node; |
46 |
|
import javax.jcr.NodeIterator; |
47 |
|
import javax.jcr.PathNotFoundException; |
48 |
|
import javax.jcr.Property; |
49 |
|
import javax.jcr.PropertyIterator; |
50 |
|
import javax.jcr.RepositoryException; |
51 |
|
import javax.jcr.Session; |
52 |
|
import javax.jcr.Value; |
53 |
|
import javax.jcr.lock.Lock; |
54 |
|
import javax.jcr.nodetype.NodeDefinition; |
55 |
|
import javax.jcr.nodetype.NodeType; |
56 |
|
import javax.jcr.version.Version; |
57 |
|
|
58 |
|
import org.apache.jackrabbit.commons.AbstractNode; |
59 |
|
import org.apache.jackrabbit.commons.iterator.NodeIteratorAdapter; |
60 |
|
import org.apache.jackrabbit.commons.iterator.PropertyIteratorAdapter; |
61 |
|
import org.apache.jackrabbit.util.ChildrenCollectorFilter; |
62 |
|
|
63 |
|
|
64 |
|
@link |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 88 (88) |
Complexity: 39 |
Complexity Density: 0.81 |
|
66 |
|
public class ReadOnlyNode extends AbstractNode { |
67 |
|
private final String name; |
68 |
|
private final Node parent; |
69 |
|
private final List<Property> properties; |
70 |
|
private final List<Node> children; |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
72 |
0 |
public ReadOnlyNode(String name, Node parent, List<Node> children, List<Property> properties) {... |
73 |
0 |
this.name = name; |
74 |
0 |
this.parent = parent; |
75 |
0 |
this.children = children; |
76 |
0 |
this.properties = properties; |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
79 |
0 |
public ReadOnlyNode(String name, Node parent, List<Item> items) {... |
80 |
0 |
this.name = name; |
81 |
0 |
this.parent = parent; |
82 |
0 |
this.children = items.stream() |
83 |
|
.filter(item -> item.isNode()) |
84 |
|
.map(item -> (Node) item) |
85 |
|
.collect(Collectors.toList()); |
86 |
0 |
this.properties = items.stream() |
87 |
|
.filter(item -> !item.isNode()) |
88 |
|
.map(item -> (Property) item) |
89 |
|
.collect(Collectors.toList()); |
90 |
|
} |
91 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
92 |
|
@Override... |
93 |
|
public String getIdentifier() throws RepositoryException { |
94 |
|
|
95 |
|
return ""; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
98 |
0 |
@Override... |
99 |
|
public String getPath() throws RepositoryException { |
100 |
0 |
StringBuffer buffer = new StringBuffer(getParent().getPath()); |
101 |
0 |
if (buffer.length() > 1) { |
102 |
0 |
buffer.append('/'); |
103 |
|
} |
104 |
0 |
buffer.append("@" + this.name); |
105 |
|
|
106 |
0 |
return buffer.toString(); |
107 |
|
} |
108 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
109 |
|
@Override... |
110 |
|
public String getName() throws RepositoryException { |
111 |
|
return this.name; |
112 |
|
} |
113 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
114 |
|
@Override... |
115 |
|
public int getIndex() throws RepositoryException { |
116 |
|
return 0; |
117 |
|
} |
118 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
119 |
|
@Override... |
120 |
|
public boolean isNew() { |
121 |
|
return false; |
122 |
|
} |
123 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
124 |
|
@Override... |
125 |
|
public boolean isModified() { |
126 |
|
return false; |
127 |
|
} |
128 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
129 |
0 |
@Override... |
130 |
|
public boolean isSame(Item item) throws RepositoryException { |
131 |
0 |
return false; |
132 |
|
} |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0 |
@Override... |
135 |
|
public void accept(ItemVisitor visitor) throws RepositoryException { |
136 |
0 |
visitor.visit(this); |
137 |
|
} |
138 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
139 |
|
@Override... |
140 |
|
public Node getParent() throws RepositoryException { |
141 |
|
return parent; |
142 |
|
} |
143 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
144 |
|
@Override... |
145 |
|
public Session getSession() throws RepositoryException { |
146 |
|
return parent.getSession(); |
147 |
|
} |
148 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
149 |
|
@Override... |
150 |
|
public NodeType getPrimaryNodeType() throws RepositoryException { |
151 |
|
return parent.getPrimaryNodeType(); |
152 |
|
} |
153 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
154 |
0 |
@Override... |
155 |
|
public Node getNode(String relPath) throws RepositoryException { |
156 |
0 |
return children.stream() |
157 |
|
.filter(node -> relPath.equals(NodeUtil.getPathIfPossible(node))) |
158 |
|
.findFirst() |
159 |
|
.orElseThrow(() -> new PathNotFoundException(String.format("%s not found!", relPath))); |
160 |
|
} |
161 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
162 |
|
@Override... |
163 |
|
public NodeIterator getNodes() throws RepositoryException { |
164 |
|
return new NodeIteratorAdapter(this.children.iterator()); |
165 |
|
} |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0 |
@Override... |
168 |
|
public NodeIterator getNodes(String namePattern) throws RepositoryException { |
169 |
0 |
return ChildrenCollectorFilter.collectChildNodes(this, namePattern); |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0 |
@Override... |
173 |
|
public NodeIterator getNodes(String[] nameGlobs) throws RepositoryException { |
174 |
0 |
return ChildrenCollectorFilter.collectChildNodes(this, nameGlobs); |
175 |
|
} |
176 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
177 |
|
@Override... |
178 |
|
public PropertyIterator getProperties() throws RepositoryException { |
179 |
|
return new PropertyIteratorAdapter(this.properties); |
180 |
|
} |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
182 |
0 |
@Override... |
183 |
|
public PropertyIterator getProperties(String namePattern) throws RepositoryException { |
184 |
0 |
return ChildrenCollectorFilter.collectProperties(this, namePattern); |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0 |
@Override... |
188 |
|
public PropertyIterator getProperties(String[] nameGlobs) throws RepositoryException { |
189 |
0 |
return ChildrenCollectorFilter.collectProperties(this, nameGlobs); |
190 |
|
} |
191 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
192 |
|
@Override... |
193 |
|
public void setPrimaryType(String primaryType) throws RepositoryException { |
194 |
|
throw new UnsupportedOperationException("Not implemented."); |
195 |
|
} |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
0 |
@Override... |
198 |
|
public Node addNode(String s) throws RepositoryException { |
199 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
200 |
|
} |
201 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
0 |
@Override... |
203 |
|
public Node addNode(String s, String s1) throws RepositoryException { |
204 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
205 |
|
} |
206 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
0 |
@Override... |
208 |
|
public void orderBefore(String s, String s1) throws RepositoryException { |
209 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
210 |
|
} |
211 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
0 |
@Override... |
213 |
|
public Property setProperty(String s, Value value) throws RepositoryException { |
214 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
215 |
|
} |
216 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
217 |
0 |
@Override... |
218 |
|
public Property setProperty(String s, Value[] values) throws RepositoryException { |
219 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
220 |
|
} |
221 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
222 |
0 |
@Override... |
223 |
|
public Property setProperty(String s, Binary binary) throws RepositoryException { |
224 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
225 |
|
} |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
227 |
0 |
@Override... |
228 |
|
public Property setProperty(String s, BigDecimal bigDecimal) throws RepositoryException { |
229 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
230 |
|
} |
231 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
232 |
|
@Override... |
233 |
|
public PropertyIterator getReferences() throws RepositoryException { |
234 |
|
throw new UnsupportedOperationException("Not implemented."); |
235 |
|
} |
236 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
237 |
0 |
@Override... |
238 |
|
public PropertyIterator getReferences(String s) throws RepositoryException { |
239 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
240 |
|
} |
241 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
242 |
|
@Override... |
243 |
|
public PropertyIterator getWeakReferences() throws RepositoryException { |
244 |
|
throw new UnsupportedOperationException("Not implemented."); |
245 |
|
} |
246 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
247 |
0 |
@Override... |
248 |
|
public PropertyIterator getWeakReferences(String s) throws RepositoryException { |
249 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
250 |
|
} |
251 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
252 |
|
@Override... |
253 |
|
public Item getPrimaryItem() throws RepositoryException { |
254 |
|
throw new UnsupportedOperationException("Not implemented."); |
255 |
|
} |
256 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
257 |
0 |
@Override... |
258 |
|
public void addMixin(String s) throws RepositoryException { |
259 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
260 |
|
} |
261 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
262 |
0 |
@Override... |
263 |
|
public void removeMixin(String s) throws RepositoryException { |
264 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
265 |
|
} |
266 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
267 |
0 |
@Override... |
268 |
|
public boolean canAddMixin(String s) throws RepositoryException { |
269 |
0 |
return false; |
270 |
|
} |
271 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
272 |
|
@Override... |
273 |
|
public NodeDefinition getDefinition() throws RepositoryException { |
274 |
|
throw new UnsupportedOperationException("Not implemented."); |
275 |
|
} |
276 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
277 |
0 |
@Override... |
278 |
|
public Version checkin() throws RepositoryException { |
279 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
280 |
|
} |
281 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
282 |
0 |
@Override... |
283 |
|
public void checkout() throws RepositoryException { |
284 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
285 |
|
} |
286 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
287 |
0 |
@Override... |
288 |
|
public void doneMerge(Version version) throws RepositoryException { |
289 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
290 |
|
} |
291 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
292 |
0 |
@Override... |
293 |
|
public void cancelMerge(Version version) throws RepositoryException { |
294 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
295 |
|
} |
296 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
297 |
0 |
@Override... |
298 |
|
public void update(String s) throws RepositoryException { |
299 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
300 |
|
} |
301 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
302 |
0 |
@Override... |
303 |
|
public NodeIterator merge(String s, boolean b) throws RepositoryException { |
304 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
305 |
|
} |
306 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
307 |
0 |
@Override... |
308 |
|
public String getCorrespondingNodePath(String s) throws RepositoryException { |
309 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
310 |
|
} |
311 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
312 |
|
@Override... |
313 |
|
public NodeIterator getSharedSet() throws RepositoryException { |
314 |
|
throw new UnsupportedOperationException("Not implemented."); |
315 |
|
} |
316 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
317 |
0 |
@Override... |
318 |
|
public void removeSharedSet() throws RepositoryException { |
319 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
320 |
|
} |
321 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
322 |
0 |
@Override... |
323 |
|
public void removeShare() throws RepositoryException { |
324 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
325 |
|
} |
326 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
327 |
0 |
@Override... |
328 |
|
public void restore(Version version, String s, boolean b) throws RepositoryException { |
329 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
330 |
|
} |
331 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
332 |
|
@Override... |
333 |
|
public Version getBaseVersion() throws RepositoryException { |
334 |
|
throw new UnsupportedOperationException("Not implemented."); |
335 |
|
} |
336 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
337 |
0 |
@Override... |
338 |
|
public Lock lock(boolean b, boolean b1) throws RepositoryException { |
339 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
340 |
|
} |
341 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
342 |
|
@Override... |
343 |
|
public Lock getLock() throws RepositoryException { |
344 |
|
throw new UnsupportedOperationException("Not implemented."); |
345 |
|
} |
346 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
347 |
0 |
@Override... |
348 |
|
public void unlock() throws RepositoryException { |
349 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
350 |
|
} |
351 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
352 |
0 |
@Override... |
353 |
|
public void followLifecycleTransition(String s) throws RepositoryException { |
354 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
355 |
|
} |
356 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
357 |
|
@Override... |
358 |
|
public String[] getAllowedLifecycleTransistions() throws RepositoryException { |
359 |
|
return new String[0]; |
360 |
|
} |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
362 |
0 |
@Override... |
363 |
|
public void save() throws RepositoryException { |
364 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
365 |
|
} |
366 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
367 |
0 |
@Override... |
368 |
|
public void refresh(boolean b) throws RepositoryException { |
369 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
370 |
|
} |
371 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
372 |
0 |
@Override... |
373 |
|
public void remove() throws RepositoryException { |
374 |
0 |
throw new UnsupportedOperationException("Not implemented."); |
375 |
|
} |
376 |
|
} |