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 com.xpn.xwiki.XWiki; |
23 |
|
import com.xpn.xwiki.XWikiContext; |
24 |
|
import com.xpn.xwiki.XWikiException; |
25 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
26 |
|
import com.xpn.xwiki.doc.XWikiDocumentArchive; |
27 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 6 |
Complexity Density: 0.27 |
|
28 |
|
public class RollbackAction extends XWikiAction |
29 |
|
{ |
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 5 |
Complexity Density: 0.24 |
|
30 |
0 |
@Override... |
31 |
|
public boolean action(XWikiContext context) throws XWikiException |
32 |
|
{ |
33 |
|
|
34 |
0 |
if (!csrfTokenCheck(context)) { |
35 |
0 |
return false; |
36 |
|
} |
37 |
|
|
38 |
0 |
RollbackForm form = (RollbackForm) context.getForm(); |
39 |
0 |
if (!"1".equals(form.getConfirm())) { |
40 |
0 |
return true; |
41 |
|
} |
42 |
|
|
43 |
0 |
XWiki xwiki = context.getWiki(); |
44 |
0 |
XWikiResponse response = context.getResponse(); |
45 |
0 |
XWikiDocument doc = context.getDoc(); |
46 |
|
|
47 |
0 |
String rev = form.getRev(); |
48 |
0 |
String language = form.getLanguage(); |
49 |
|
|
50 |
|
|
51 |
0 |
XWikiDocument tdoc = getTranslatedDocument(doc, language, context); |
52 |
|
|
53 |
|
|
54 |
0 |
if ("previous".equals(rev)) { |
55 |
0 |
XWikiDocumentArchive archive = tdoc.loadDocumentArchive(); |
56 |
|
|
57 |
|
|
58 |
0 |
Object previousVersion = archive.getPrevVersion(archive.getLatestVersion()); |
59 |
0 |
if (previousVersion != null) { |
60 |
0 |
rev = previousVersion.toString(); |
61 |
|
} else { |
62 |
|
|
63 |
0 |
rev = "-1"; |
64 |
|
} |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
0 |
xwiki.rollback(tdoc, rev, context); |
69 |
|
|
70 |
|
|
71 |
0 |
String redirect = Utils.getRedirect("view", context); |
72 |
0 |
sendRedirect(response, redirect); |
73 |
0 |
return false; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0 |
@Override... |
77 |
|
public String render(XWikiContext context) throws XWikiException |
78 |
|
{ |
79 |
0 |
return "rollback"; |
80 |
|
} |
81 |
|
} |