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