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

File XWikiDavSessionProvider.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

4
13
2
1
63
33
6
0.46
6.5
2
3

Classes

Class Line # Actions
XWikiDavSessionProvider 32 13 0% 6 4
0.789473778.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.utils;
21   
22    import org.apache.jackrabbit.webdav.DavException;
23    import org.apache.jackrabbit.webdav.DavSession;
24    import org.apache.jackrabbit.webdav.DavSessionProvider;
25    import org.apache.jackrabbit.webdav.WebdavRequest;
26   
27    /**
28    * Responsible for associating / detaching session information into incoming WebDAV requests.
29    *
30    * @version $Id: 0eae287ea85305f49e7db1e83de3b6e33fdbfc4c $.
31    */
 
32    public class XWikiDavSessionProvider implements DavSessionProvider
33    {
 
34  77 toggle @Override
35    public boolean attachSession(WebdavRequest request) throws DavException
36    {
37    // Retrieve the workspace name.
38  77 String workspaceName = request.getRequestLocator().getWorkspaceName();
39    // Empty workspaceName rather means default (null).
40  77 if (workspaceName != null && "".equals(workspaceName)) {
41  0 workspaceName = null;
42    }
43  77 DavSession ds = new XWikiDavSession();
44  77 request.setDavSession(ds);
45  77 return true;
46    }
47   
 
48  77 toggle @Override
49    public void releaseSession(WebdavRequest request)
50    {
51  77 DavSession ds = request.getDavSession();
52  77 if (ds != null && ds instanceof XWikiDavSession) {
53  77 XWikiDavSession session = (XWikiDavSession) ds;
54  77 String[] lockTokens = session.getLockTokens();
55  77 for (String token : lockTokens) {
56  0 session.removeLockToken(token);
57    }
58    } else {
59    // session is null. nothing to be done.
60    }
61  77 request.setDavSession(null);
62    }
63    }