| 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 org.apache.commons.lang3.StringUtils; |
| 23 |
|
|
| 24 |
|
import com.xpn.xwiki.XWikiContext; |
| 25 |
|
import com.xpn.xwiki.XWikiException; |
| 26 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@version |
| 42 |
|
|
| |
|
| 55.1% |
Uncovered Elements: 22 (49) |
Complexity: 13 |
Complexity Density: 0.45 |
|
| 43 |
|
public class PreviewAction extends EditAction |
| 44 |
|
{ |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
41 |
public PreviewAction()... |
| 49 |
|
{ |
| 50 |
41 |
this.waitForXWikiInitialization = true; |
| 51 |
|
} |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@link |
| 56 |
|
|
| 57 |
|
@param |
| 58 |
|
@return |
| 59 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 60 |
9 |
private boolean isActionSelected(String action)... |
| 61 |
|
{ |
| 62 |
9 |
return StringUtils.isNotEmpty(action); |
| 63 |
|
} |
| 64 |
|
|
| |
|
| 34.4% |
Uncovered Elements: 21 (32) |
Complexity: 7 |
Complexity Density: 0.35 |
|
| 65 |
3 |
@Override... |
| 66 |
|
public boolean action(XWikiContext context) throws XWikiException |
| 67 |
|
{ |
| 68 |
3 |
XWikiRequest request = context.getRequest(); |
| 69 |
3 |
String formactionsave = request.getParameter("formactionsave"); |
| 70 |
3 |
String formactioncancel = request.getParameter("formactioncancel"); |
| 71 |
3 |
String formactionsac = request.getParameter("formactionsac"); |
| 72 |
|
|
| 73 |
3 |
if (isActionSelected(formactionsave)) { |
| 74 |
0 |
SaveAction sa = new SaveAction(); |
| 75 |
0 |
if (sa.action(context)) { |
| 76 |
0 |
sa.render(context); |
| 77 |
|
} |
| 78 |
0 |
return false; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
3 |
if (isActionSelected(formactioncancel)) { |
| 82 |
0 |
CancelAction ca = new CancelAction(); |
| 83 |
0 |
if (ca.action(context)) { |
| 84 |
0 |
ca.render(context); |
| 85 |
|
} |
| 86 |
0 |
return false; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
3 |
if (isActionSelected(formactionsac)) { |
| 90 |
0 |
SaveAndContinueAction saca = new SaveAndContinueAction(); |
| 91 |
0 |
if (saca.action(context)) { |
| 92 |
0 |
saca.render(context); |
| 93 |
|
} |
| 94 |
0 |
return false; |
| 95 |
|
} |
| 96 |
3 |
return true; |
| 97 |
|
} |
| 98 |
|
|
| |
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 99 |
3 |
@Override... |
| 100 |
|
public String render(XWikiContext context) throws XWikiException |
| 101 |
|
{ |
| 102 |
3 |
XWikiDocument editedDocument = prepareEditedDocument(context); |
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
3 |
editedDocument.setAuthorReference(context.getUserReference()); |
| 107 |
3 |
if (editedDocument.isNew()) { |
| 108 |
1 |
editedDocument.setCreatorReference(context.getUserReference()); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
3 |
editedDocument.setContentAuthorReference(context.getUserReference()); |
| 115 |
|
|
| 116 |
|
|
| 117 |
3 |
Boolean reCheckCaptcha = (Boolean) context.get("recheckcaptcha"); |
| 118 |
3 |
return reCheckCaptcha != null && reCheckCaptcha ? "captcha" : "preview"; |
| 119 |
|
} |
| 120 |
|
} |