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 java.io.IOException; |
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 |
|
@version |
33 |
|
|
|
|
| 69.2% |
Uncovered Elements: 8 (26) |
Complexity: 7 |
Complexity Density: 0.37 |
|
34 |
|
public class ViewAction extends XWikiAction |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
public static final String VIEW_ACTION = "view"; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
29 |
public ViewAction()... |
45 |
|
{ |
46 |
29 |
this.waitForXWikiInitialization = false; |
47 |
29 |
this.handleRedirectObject = true; |
48 |
|
} |
49 |
|
|
|
|
| 53.8% |
Uncovered Elements: 6 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
50 |
604 |
@Override... |
51 |
|
public boolean action(XWikiContext context) throws XWikiException |
52 |
|
{ |
53 |
604 |
boolean shouldRender = true; |
54 |
|
|
55 |
604 |
context.put("action", VIEW_ACTION); |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
604 |
XWikiRequest request = context.getRequest(); |
60 |
604 |
String rev = request.getParameter("rev"); |
61 |
604 |
if (rev != null) { |
62 |
0 |
String url = context.getDoc().getURL("viewrev", request.getQueryString(), context); |
63 |
0 |
try { |
64 |
0 |
context.getResponse().sendRedirect(url); |
65 |
|
} catch (IOException e) { |
66 |
0 |
e.printStackTrace(); |
67 |
|
} |
68 |
0 |
shouldRender = false; |
69 |
|
} |
70 |
|
|
71 |
604 |
return shouldRender; |
72 |
|
} |
73 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
74 |
604 |
@Override... |
75 |
|
public String render(XWikiContext context) throws XWikiException |
76 |
|
{ |
77 |
604 |
handleRevision(context); |
78 |
604 |
XWikiDocument doc = (XWikiDocument) context.get("doc"); |
79 |
|
|
80 |
604 |
String defaultTemplate = doc.getDefaultTemplate(); |
81 |
604 |
if ((defaultTemplate != null) && (!defaultTemplate.equals(""))) { |
82 |
0 |
return defaultTemplate; |
83 |
|
} else { |
84 |
604 |
return VIEW_ACTION; |
85 |
|
} |
86 |
|
} |
87 |
|
} |