1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.web

File LockAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

6
18
1
1
62
36
5
0.28
18
1
5

Classes

Class Line # Actions
LockAction 29 18 0% 5 3
0.8888%
 

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.web;
21   
22    import javax.servlet.http.HttpServletResponse;
23   
24    import com.xpn.xwiki.XWikiContext;
25    import com.xpn.xwiki.XWikiException;
26    import com.xpn.xwiki.doc.XWikiDocument;
27    import com.xpn.xwiki.doc.XWikiLock;
28   
 
29    public class LockAction extends XWikiAction
30    {
 
31  822 toggle @Override
32    public boolean action(XWikiContext context) throws XWikiException
33    {
34  825 XWikiRequest request = context.getRequest();
35  830 XWikiResponse response = context.getResponse();
36  828 XWikiDocument doc = context.getDoc();
37  829 XWikiForm form = context.getForm();
38   
39  825 String language = ((EditForm) form).getLanguage();
40  828 XWikiDocument tdoc = getTranslatedDocument(doc, language, context);
41   
42  831 String username = context.getUser();
43  830 XWikiLock lock = tdoc.getLock(context);
44  829 if ((lock == null) || (username.equals(lock.getUserName()))) {
45  826 if ("inline".equals(request.get("action"))) {
46  6 doc.setLock(username, context);
47    } else {
48  820 tdoc.setLock(username, context);
49    }
50    }
51   
52    // forward to view
53  832 if (Utils.isAjaxRequest(context)) {
54  832 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
55  832 response.setContentLength(0);
56    } else {
57  0 String redirect = Utils.getRedirect("view", context);
58  0 sendRedirect(response, redirect);
59    }
60  832 return false;
61    }
62    }