1. Project Clover database Tue Dec 20 2016 21:24:09 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  228 toggle @Override
32    public boolean action(XWikiContext context) throws XWikiException
33    {
34  228 XWikiRequest request = context.getRequest();
35  228 XWikiResponse response = context.getResponse();
36  228 XWikiDocument doc = context.getDoc();
37  228 XWikiForm form = context.getForm();
38   
39  228 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  228 XWikiDocument tdoc = getTranslatedDocument(doc, language, context);
44   
45  228 String username = context.getUser();
46  228 try {
47  228 XWikiLock lock = tdoc.getLock(context);
48  228 if (lock != null && lock.getUserName().equals(username)) {
49  204 if ("inline".equals(request.get("action"))) {
50  0 doc.removeLock(context);
51    } else {
52  204 tdoc.removeLock(context);
53    }
54    }
55    } catch (Exception ex) {
56    // Just ignore this, locks aren't critical.
57    }
58   
59    // forward to view
60  228 if (Utils.isAjaxRequest(context)) {
61  225 response.setStatus(HttpServletResponse.SC_NO_CONTENT);
62  225 response.setContentLength(0);
63    } else {
64  3 String redirect = Utils.getRedirect("view", context);
65  3 sendRedirect(response, redirect);
66    }
67  228 return false;
68    }
69    }