1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.index.tree.internal.nestedpages; |
21 |
|
|
22 |
|
import java.util.Collections; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.apache.commons.lang3.StringUtils; |
26 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
27 |
|
import org.xwiki.index.tree.internal.AbstractEntityTreeNode; |
28 |
|
import org.xwiki.model.EntityType; |
29 |
|
import org.xwiki.model.reference.DocumentReference; |
30 |
|
import org.xwiki.model.reference.EntityReference; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
@since |
38 |
|
|
|
|
| 59.5% |
Uncovered Elements: 17 (42) |
Complexity: 18 |
Complexity Density: 0.69 |
|
39 |
|
public abstract class AbstractDocumentTreeNode extends AbstractEntityTreeNode |
40 |
|
{ |
41 |
|
private final String nodeType; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@param |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
576 |
public AbstractDocumentTreeNode(String nodeType)... |
49 |
|
{ |
50 |
576 |
this.nodeType = nodeType; |
51 |
|
} |
52 |
|
|
|
|
| 62.5% |
Uncovered Elements: 3 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
53 |
10 |
@Override... |
54 |
|
public List<String> getChildren(String nodeId, int offset, int limit) |
55 |
|
{ |
56 |
10 |
EntityReference documentReference = resolve(nodeId); |
57 |
10 |
if (documentReference != null && documentReference.getType() == EntityType.DOCUMENT) { |
58 |
10 |
try { |
59 |
10 |
return getChildren(new DocumentReference(documentReference), offset, limit); |
60 |
|
} catch (Exception e) { |
61 |
0 |
this.logger.warn("Failed to retrieve the children of [{}]. Root cause [{}].", nodeId, |
62 |
|
ExceptionUtils.getRootCauseMessage(e)); |
63 |
|
} |
64 |
|
} |
65 |
0 |
return Collections.emptyList(); |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0 |
protected List<String> getChildren(DocumentReference documentReference, int offset, int limit) throws Exception... |
69 |
|
{ |
70 |
0 |
return Collections.emptyList(); |
71 |
|
} |
72 |
|
|
|
|
| 62.5% |
Uncovered Elements: 3 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
73 |
118 |
@Override... |
74 |
|
public int getChildCount(String nodeId) |
75 |
|
{ |
76 |
118 |
EntityReference documentReference = resolve(nodeId); |
77 |
118 |
if (documentReference != null && documentReference.getType() == EntityType.DOCUMENT) { |
78 |
118 |
try { |
79 |
118 |
return getChildCount(new DocumentReference(documentReference)); |
80 |
|
} catch (Exception e) { |
81 |
0 |
this.logger.warn("Failed to count the children of [{}]. Root cause [{}].", nodeId, |
82 |
|
ExceptionUtils.getRootCauseMessage(e)); |
83 |
|
} |
84 |
|
} |
85 |
0 |
return 0; |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
0 |
protected int getChildCount(DocumentReference documentReference) throws Exception... |
89 |
|
{ |
90 |
0 |
return 0; |
91 |
|
} |
92 |
|
|
|
|
| 62.5% |
Uncovered Elements: 3 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
93 |
5 |
@Override... |
94 |
|
public String getParent(String nodeId) |
95 |
|
{ |
96 |
5 |
EntityReference documentReference = resolve(nodeId); |
97 |
5 |
if (documentReference != null && documentReference.getType() == EntityType.DOCUMENT) { |
98 |
5 |
try { |
99 |
5 |
return serialize(getParent(new DocumentReference(documentReference))); |
100 |
|
} catch (Exception e) { |
101 |
0 |
this.logger.warn("Failed to retrieve the parent of [{}]. Root cause [{}].", nodeId, |
102 |
|
ExceptionUtils.getRootCauseMessage(e)); |
103 |
|
} |
104 |
|
} |
105 |
0 |
return null; |
106 |
|
} |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
0 |
protected EntityReference getParent(DocumentReference documentReference) throws Exception... |
109 |
|
{ |
110 |
|
|
111 |
0 |
return documentReference; |
112 |
|
} |
113 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
114 |
133 |
@Override... |
115 |
|
protected EntityReference resolve(String nodeId) |
116 |
|
{ |
117 |
133 |
String prefix = this.nodeType + ':'; |
118 |
133 |
if (StringUtils.startsWith(nodeId, prefix)) { |
119 |
133 |
return super.resolve("document:" + nodeId.substring(prefix.length())); |
120 |
|
} |
121 |
0 |
return null; |
122 |
|
} |
123 |
|
} |