1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.mandatory; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Provider; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
|
29 |
|
import com.xpn.xwiki.XWiki; |
30 |
|
import com.xpn.xwiki.XWikiContext; |
31 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
32 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Named("XWiki.GlobalRedirect") |
42 |
|
@Singleton |
|
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
43 |
|
public class GlobalRedirectDocumentInitializer extends AbstractMandatoryDocumentInitializer |
44 |
|
{ |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@Inject |
49 |
|
private Provider<XWikiContext> xcontextProvider; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
60 |
public GlobalRedirectDocumentInitializer()... |
55 |
|
{ |
56 |
60 |
super(XWiki.SYSTEM_SPACE, "GlobalRedirect"); |
57 |
|
} |
58 |
|
|
|
|
| 50% |
Uncovered Elements: 5 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
59 |
92 |
@Override... |
60 |
|
public boolean updateDocument(XWikiDocument document) |
61 |
|
{ |
62 |
92 |
boolean needsUpdate = false; |
63 |
|
|
64 |
92 |
XWikiContext xcontext = this.xcontextProvider.get(); |
65 |
|
|
66 |
|
|
67 |
92 |
if (xcontext.isMainWiki() && "1".equals(xcontext.getWiki().Param("xwiki.preferences.redirect"))) { |
68 |
0 |
BaseClass bclass = document.getXClass(); |
69 |
|
|
70 |
0 |
needsUpdate |= bclass.addTextField("pattern", "Pattern", 30); |
71 |
0 |
needsUpdate |= bclass.addTextField("destination", "Destination", 30); |
72 |
0 |
needsUpdate |= setClassDocumentFields(document, "XWiki Global Redirect Class"); |
73 |
|
} |
74 |
|
|
75 |
92 |
return needsUpdate; |
76 |
|
} |
77 |
|
} |