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.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.Collections; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import javax.inject.Inject; |
28 |
|
import javax.inject.Named; |
29 |
|
|
30 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
33 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
34 |
|
import org.xwiki.tree.AbstractTreeNode; |
35 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
36 |
|
import org.xwiki.wiki.manager.WikiManagerException; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Named("farm") |
47 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.4 |
|
48 |
|
public class FarmTreeNode extends AbstractTreeNode |
49 |
|
{ |
50 |
|
@Inject |
51 |
|
private WikiDescriptorManager wikiDescriptorManager; |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
53 |
0 |
@Override... |
54 |
|
public List<String> getChildren(String nodeId, int offset, int limit) |
55 |
|
{ |
56 |
0 |
List<String> wikiIds = new ArrayList<String>(getWikiIds()); |
57 |
0 |
List<String> children = new ArrayList<String>(); |
58 |
0 |
for (String wikiId : subList(wikiIds, offset, limit)) { |
59 |
0 |
children.add("wiki:" + wikiId); |
60 |
|
} |
61 |
0 |
return children; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0 |
@Override... |
65 |
|
public int getChildCount(String nodeId) |
66 |
|
{ |
67 |
0 |
return getWikiIds().size(); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
70 |
0 |
private Collection<String> getWikiIds()... |
71 |
|
{ |
72 |
0 |
try { |
73 |
0 |
return this.wikiDescriptorManager.getAllIds(); |
74 |
|
} catch (WikiManagerException e) { |
75 |
0 |
this.logger.warn("Failed to retrieve the list of wikis. Root cause [{}].", |
76 |
|
ExceptionUtils.getRootCauseMessage(e)); |
77 |
0 |
return Collections.emptyList(); |
78 |
|
} |
79 |
|
} |
80 |
|
} |