| 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 |
|
|
| |
|
| 88% |
Uncovered Elements: 3 (25) |
Complexity: 5 |
Complexity Density: 0.28 |
|
| 29 |
|
public class LockAction extends XWikiAction |
| 30 |
|
{ |
| |
|
| 87.5% |
Uncovered Elements: 3 (24) |
Complexity: 5 |
Complexity Density: 0.28 |
|
| 31 |
272 |
@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 |
|
|
| 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 |
|
} |