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

File CancelAction.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

6
19
1
1
69
39
6
0.32
19
1
6

Classes

Class Line # Actions
CancelAction 29 19 0% 6 2
0.923076992.3%
 

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 CancelAction extends XWikiAction
30    {
 
31  586 toggle @Override
32    public boolean action(XWikiContext context) throws XWikiException
33    {
34  586 XWikiRequest request = context.getRequest();
35  586 XWikiResponse response = context.getResponse();
36  586 XWikiDocument doc = context.getDoc();
37  586 XWikiForm form = context.getForm();
38   
39  586 String language = ((EditForm) form).getLanguage();
40    // FIXME Which one should be used: doc.getDefaultLanguage or
41    // form.getDefaultLanguage()?
42    // String defaultLanguage = ((EditForm)form).getDefaultLanguage();
43  586 XWikiDocument tdoc = getTranslatedDocument(doc, language, context);
44   
45  586 String username = context.getUser();
46  586 try {
47  586 XWikiLock lock = tdoc.getLock(context);
48  586 if (lock != null && lock.getUserName().equals(username)) {
49  535 if ("inline".equals(request.get("action"))) {
50  0 doc.removeLock(context);
51    } else {
52  535 tdoc.removeLock(context);
53    }
54    }
55    } catch (Exception ex) {
56    // Just ignore this, locks aren't critical.
57    }
58   
59    // forward to view
60  586 if (Utils.isAjaxRequest(context)) {
61  573 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
62  573 response.setContentLength(0);
63    } else {
64  13 String redirect = Utils.getRedirect("view", context);
65  13 sendRedirect(response, redirect);
66    }
67  586 return false;
68    }
69    }