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

File WhatsnewView.java

 

Coverage histogram

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

Code metrics

8
21
2
1
85
52
9
0.43
10.5
2
4.5

Classes

Class Line # Actions
WhatsnewView 42 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 would list the last 20 modified pages.
39    *
40    * @version $Id: 1156dd3dcf8287fdd03914eee5f92173cc5b09f4 $
41    */
 
42    public class WhatsnewView extends AbstractDavView
43    {
44    /**
45    * Logger instance.
46    */
47    private static final Logger logger = LoggerFactory.getLogger(WhatsnewView.class);
48   
 
49  0 toggle @Override
50    public XWikiDavResource decode(String[] tokens, int next) throws DavException
51    {
52  0 String nextToken = tokens[next];
53  0 boolean last = (next == tokens.length - 1);
54  0 if (isTempResource(nextToken)) {
55  0 return super.decode(tokens, next);
56  0 } else if (getContext().exists(nextToken) && !(last && getContext().isCreateOrMoveRequest())) {
57  0 DavPage page = new DavPage();
58  0 page.init(this, nextToken, "/" + nextToken);
59  0 return last ? page : page.decode(tokens, next + 1);
60    } else {
61  0 throw new DavException(DavServletResponse.SC_BAD_REQUEST);
62    }
63    }
64   
 
65  0 toggle @Override
66    public DavResourceIterator getMembers()
67    {
68  0 List<DavResource> children = new ArrayList<DavResource>();
69  0 String sql = "where 1=1 order by doc.date desc";
70  0 try {
71  0 List<String> docNames = getContext().searchDocumentsNames(sql, 20, 0);
72  0 for (String docName : docNames) {
73  0 if (getContext().hasAccess("view", docName)) {
74  0 DavPage page = new DavPage();
75  0 page.init(this, docName, "/" + docName);
76  0 children.add(page);
77    }
78    }
79    } catch (DavException e) {
80  0 logger.error("Unexpected Error : ", e);
81    }
82  0 children.addAll(getVirtualMembers());
83  0 return new DavResourceIteratorImpl(children);
84    }
85    }