1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.index.tree.internal.nestedpages

File FarmTreeNode.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
10
3
1
80
47
4
0.4
3.33
3
1.33

Classes

Class Line # Actions
FarmTreeNode 48 10 0% 4 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * The farm tree node.
40    *
41    * @version $Id: f123e311249836af5d368dbf5461ce8f9171e936 $
42    * @since 8.3M2
43    * @since 7.4.5
44    */
45    @Component
46    @Named("farm")
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
48    public class FarmTreeNode extends AbstractTreeNode
49    {
50    @Inject
51    private WikiDescriptorManager wikiDescriptorManager;
52   
 
53  0 toggle @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   
 
64  0 toggle @Override
65    public int getChildCount(String nodeId)
66    {
67  0 return getWikiIds().size();
68    }
69   
 
70  0 toggle 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    }