1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.webdav.resources.views

File OrphansView.java

 

Coverage histogram

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

Code metrics

8
21
2
1
86
52
9
0.43
10.5
2
4.5

Classes

Class Line # Actions
OrphansView 43 21 0% 9 31
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 com.xpn.xwiki.plugin.webdav.resources.views;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.apache.jackrabbit.webdav.DavException;
26    import org.apache.jackrabbit.webdav.DavResource;
27    import org.apache.jackrabbit.webdav.DavResourceIterator;
28    import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
29    import org.apache.jackrabbit.webdav.DavServletResponse;
30    import org.slf4j.Logger;
31    import org.slf4j.LoggerFactory;
32   
33    import com.xpn.xwiki.plugin.webdav.resources.XWikiDavResource;
34    import com.xpn.xwiki.plugin.webdav.resources.domain.DavPage;
35    import com.xpn.xwiki.plugin.webdav.resources.partial.AbstractDavView;
36   
37    /**
38    * This view allows to view the other entry points in the wiki that are not linked to 'Main.WebHome'. All pages that do
39    * not have a parent that exists in the wiki are shown in this view.
40    *
41    * @version $Id: 0e56231e5e43d2065e7b579bc18ac1c3529e1786 $
42    */
 
43    public class OrphansView extends AbstractDavView
44    {
45    /**
46    * Logger instance.
47    */
48    private static final Logger logger = LoggerFactory.getLogger(OrphansView.class);
49   
 
50  0 toggle @Override
51    public XWikiDavResource decode(String[] tokens, int next) throws DavException
52    {
53  0 String nextToken = tokens[next];
54  0 boolean last = (next == tokens.length - 1);
55  0 if (isTempResource(nextToken)) {
56  0 return super.decode(tokens, next);
57  0 } else if (getContext().exists(nextToken) && !(last && getContext().isCreateOrMoveRequest())) {
58  0 DavPage page = new DavPage();
59  0 page.init(this, nextToken, "/" + nextToken);
60  0 return last ? page : page.decode(tokens, next + 1);
61    } else {
62  0 throw new DavException(DavServletResponse.SC_BAD_REQUEST);
63    }
64    }
65   
 
66  0 toggle @Override
67    public DavResourceIterator getMembers()
68    {
69  0 List<DavResource> children = new ArrayList<DavResource>();
70  0 String sql = "where doc.parent not in (select doc2.fullName from XWikiDocument as doc2)";
71  0 try {
72  0 List<String> docNames = getContext().searchDocumentsNames(sql);
73  0 for (String docName : docNames) {
74  0 if (getContext().hasAccess("view", docName)) {
75  0 DavPage page = new DavPage();
76  0 page.init(this, docName, "/" + docName);
77  0 children.add(page);
78    }
79    }
80    } catch (DavException e) {
81  0 logger.error("Unexpected Error : ", e);
82    }
83  0 children.addAll(getVirtualMembers());
84  0 return new DavResourceIteratorImpl(children);
85    }
86    }