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

File RootView.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

16
40
2
1
104
71
12
0.3
20
2
6

Classes

Class Line # Actions
RootView 44 40 0% 12 3
0.9482758694.8%
 

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.partial.AbstractDavView;
35    import com.xpn.xwiki.plugin.webdav.resources.views.attachments.AttachmentsView;
36    import com.xpn.xwiki.plugin.webdav.resources.views.pages.PagesView;
37    import com.xpn.xwiki.plugin.webdav.utils.XWikiDavUtils.BaseViews;
38   
39    /**
40    * The root of all views (entry point).
41    *
42    * @version $Id: 51e10e772e476f2f7822d9f7a50fb8367b528f4d $
43    */
 
44    public class RootView extends AbstractDavView
45    {
46    /**
47    * Logger instance.
48    */
49    private static final Logger logger = LoggerFactory.getLogger(RootView.class);
50   
 
51  83 toggle @Override
52    public XWikiDavResource decode(String[] tokens, int next) throws DavException
53    {
54  83 String nextToken = tokens[next];
55  83 boolean last = (next == tokens.length - 1);
56  83 XWikiDavResource resource = null;
57  83 if (isTempResource(nextToken)) {
58  26 return super.decode(tokens, next);
59  57 } else if (last && getContext().isCreateOrMoveRequest()) {
60  14 throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
61  43 } else if (nextToken.equals(BaseViews.HOME)) {
62  1 resource = new HomeView();
63  42 } else if (nextToken.equals(BaseViews.PAGES)) {
64  39 resource = new PagesView();
65  3 } else if (nextToken.equals(BaseViews.ORPHANS)) {
66  1 resource = new OrphansView();
67  2 } else if (nextToken.equals(BaseViews.WHATSNEW)) {
68  1 resource = new WhatsnewView();
69  1 } else if (nextToken.equals(BaseViews.ATTACHMENTS)) {
70  1 resource = new AttachmentsView();
71    } else {
72  0 throw new DavException(DavServletResponse.SC_BAD_REQUEST);
73    }
74  43 resource.init(this, nextToken, "/" + nextToken);
75  43 return last ? resource : resource.decode(tokens, next + 1);
76    }
77   
 
78  1 toggle @Override
79    public DavResourceIterator getMembers()
80    {
81  1 List<DavResource> children = new ArrayList<DavResource>();
82  1 try {
83  1 XWikiDavResource homeView = new HomeView();
84  1 homeView.init(this, "home", "/home");
85  1 children.add(homeView);
86  1 XWikiDavResource pagesView = new PagesView();
87  1 pagesView.init(this, "spaces", "/spaces");
88  1 children.add(pagesView);
89  1 XWikiDavResource attachmentsView = new AttachmentsView();
90  1 attachmentsView.init(this, "attachments", "/attachments");
91  1 children.add(attachmentsView);
92  1 XWikiDavResource orphansView = new OrphansView();
93  1 orphansView.init(this, "orphans", "/orphans");
94  1 children.add(orphansView);
95  1 XWikiDavResource whatsnewView = new WhatsnewView();
96  1 whatsnewView.init(this, "whatsnew", "/whatsnew");
97  1 children.add(whatsnewView);
98    } catch (DavException e) {
99  0 logger.error("Unexpected Error : ", e);
100    }
101  1 children.addAll(getVirtualMembers());
102  1 return new DavResourceIteratorImpl(children);
103    }
104    }