1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimacro.internal; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.slf4j.Logger; |
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.context.Execution; |
31 |
|
import org.xwiki.model.reference.DocumentReference; |
32 |
|
import org.xwiki.rendering.internal.macro.wikibridge.WikiMacroBindingInitializer; |
33 |
|
import org.xwiki.rendering.macro.wikibridge.WikiMacroParameters; |
34 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWikiContext; |
37 |
|
import com.xpn.xwiki.XWikiException; |
38 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
46 |
|
@Component |
47 |
|
@Singleton |
48 |
|
@Named("core") |
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
49 |
|
public class CoreWikiMacroBindingInitializer implements WikiMacroBindingInitializer |
50 |
|
{ |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
private static final String MACRO_DOC_KEY = "doc"; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
@Inject |
61 |
|
private Execution execution; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@Inject |
67 |
|
private Logger logger; |
68 |
|
|
69 |
|
|
70 |
|
@return |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
438 |
private XWikiContext getContext()... |
73 |
|
{ |
74 |
438 |
return (XWikiContext) this.execution.getContext().getProperty("xwikicontext"); |
75 |
|
} |
76 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
77 |
146 |
@Override... |
78 |
|
public void initialize(DocumentReference macroDocumentReference, WikiMacroParameters parameters, |
79 |
|
String macroContent, MacroTransformationContext context, Map<String, Object> macroBinding) |
80 |
|
{ |
81 |
146 |
try { |
82 |
146 |
XWikiDocument document = getContext().getWiki().getDocument(macroDocumentReference, getContext()); |
83 |
146 |
macroBinding.put(MACRO_DOC_KEY, document.newDocument(getContext())); |
84 |
|
} catch (XWikiException e) { |
85 |
0 |
this.logger.error("Failed to get document " + macroDocumentReference, e); |
86 |
|
} |
87 |
|
} |
88 |
|
} |