1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
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 |
|
|
|
|
| 92.3% |
Uncovered Elements: 2 (26) |
Complexity: 6 |
Complexity Density: 0.32 |
|
29 |
|
public class CancelAction extends XWikiAction |
30 |
|
{ |
|
|
| 92% |
Uncovered Elements: 2 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
31 |
228 |
@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 |
|
|
41 |
|
|
42 |
|
|
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 |
|
|
57 |
|
} |
58 |
|
|
59 |
|
|
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 |
|
} |