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

File LockAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% 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  272 toggle @Override
32    public boolean action(XWikiContext context) throws XWikiException
33    {
34  272 XWikiRequest request = context.getRequest();
35  272 XWikiResponse response = context.getResponse();
36  272 XWikiDocument doc = context.getDoc();
37  272 XWikiForm form = context.getForm();
38   
39  272 String language = ((EditForm) form).getLanguage();
40  272 XWikiDocument tdoc = getTranslatedDocument(doc, language, context);
41   
42  272 String username = context.getUser();
43  272 XWikiLock lock = tdoc.getLock(context);
44  272 if ((lock == null) || (username.equals(lock.getUserName()))) {
45  269 if ("inline".equals(request.get("action"))) {
46  4 doc.setLock(username, context);
47    } else {
48  263 tdoc.setLock(username, context);
49    }
50    }
51   
52    // forward to view
53  272 if (Utils.isAjaxRequest(context)) {
54  272 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
55  272 response.setContentLength(0);
56    } else {
57  0 String redirect = Utils.getRedirect("view", context);
58  0 sendRedirect(response, redirect);
59    }
60  272 return false;
61    }
62    }