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

File HomeView.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart2.png
81% of files have more coverage

Code metrics

14
18
7
1
104
67
14
0.78
2.57
7
2

Classes

Class Line # Actions
HomeView 39 18 0% 14 32
0.1794871817.9%
 

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 org.apache.jackrabbit.webdav.DavException;
23    import org.apache.jackrabbit.webdav.DavResource;
24    import org.apache.jackrabbit.webdav.DavResourceIterator;
25    import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
26    import org.apache.jackrabbit.webdav.DavServletResponse;
27    import org.apache.jackrabbit.webdav.io.InputContext;
28    import org.apache.jackrabbit.webdav.property.DavPropertySet;
29   
30    import com.xpn.xwiki.plugin.webdav.resources.XWikiDavResource;
31    import com.xpn.xwiki.plugin.webdav.resources.domain.DavPage;
32    import com.xpn.xwiki.plugin.webdav.resources.partial.AbstractDavView;
33   
34    /**
35    * This view allows to browse the pages starting from Main.WebHome using the parent child relationship.
36    *
37    * @version $Id: e70d46c0a431ec29e37db14f324513df8b7fa12d $
38    */
 
39    public class HomeView extends AbstractDavView
40    {
41    /**
42    * {@link DavPage} representing Main.WebHome.
43    */
44    private DavPage mPage;
45   
 
46  2 toggle @Override
47    public void init(XWikiDavResource parent, String name, String relativePath) throws DavException
48    {
49  2 super.init(parent, name, relativePath);
50  2 mPage = new DavPage();
51  2 mPage.init(this, "Main.WebHome", "");
52    }
53   
 
54  0 toggle @Override
55    public XWikiDavResource decode(String[] tokens, int next) throws DavException
56    {
57  0 String nextToken = tokens[next];
58  0 if (mPage.exists()) {
59  0 return mPage.decode(tokens, next);
60  0 } else if (isTempResource(nextToken)) {
61  0 return super.decode(tokens, next);
62    } else {
63  0 throw new DavException(DavServletResponse.SC_BAD_REQUEST);
64    }
65    }
66   
 
67  0 toggle @Override
68    public long getModificationTime()
69    {
70  0 return mPage.exists() ? mPage.getModificationTime() : super.getModificationTime();
71    }
72   
 
73  1 toggle @Override
74    public DavPropertySet getProperties()
75    {
76  1 return mPage.exists() ? mPage.getProperties() : super.getProperties();
77    }
78   
 
79  0 toggle @Override
80    public DavResourceIterator getMembers()
81    {
82  0 return mPage.exists() ? mPage.getMembers() : new DavResourceIteratorImpl(getVirtualMembers());
83    }
84   
 
85  0 toggle @Override
86    public void addMember(DavResource resource, InputContext inputContext) throws DavException
87    {
88  0 if (mPage.exists()) {
89  0 mPage.addMember(resource, inputContext);
90    } else {
91  0 super.addVirtualMember(resource, inputContext);
92    }
93    }
94   
 
95  0 toggle @Override
96    public void removeMember(DavResource member) throws DavException
97    {
98  0 if (mPage.exists()) {
99  0 mPage.removeMember(member);
100    } else {
101  0 super.removeMember(member);
102    }
103    }
104    }