1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.executor; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.model.reference.EntityReference; |
28 |
|
import org.xwiki.rendering.block.XDOM; |
29 |
|
import org.xwiki.rendering.executor.ContentExecutor; |
30 |
|
import org.xwiki.rendering.executor.ContentExecutorException; |
31 |
|
import org.xwiki.rendering.parser.ContentParser; |
32 |
|
import org.xwiki.rendering.parser.MissingParserException; |
33 |
|
import org.xwiki.rendering.parser.ParseException; |
34 |
|
import org.xwiki.rendering.syntax.Syntax; |
35 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
36 |
|
import org.xwiki.rendering.transformation.Transformation; |
37 |
|
import org.xwiki.rendering.transformation.TransformationException; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
45 |
|
@Component |
46 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.44 |
|
47 |
|
public class MacroContentExecutor implements ContentExecutor<MacroTransformationContext> |
48 |
|
{ |
49 |
|
@Inject |
50 |
|
private ContentParser contentParser; |
51 |
|
|
52 |
|
@Inject |
53 |
|
@Named("macro") |
54 |
|
private Transformation macroTransformation; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
56 |
2 |
@Override... |
57 |
|
public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) |
58 |
|
throws ParseException, MissingParserException, ContentExecutorException |
59 |
|
{ |
60 |
2 |
XDOM xdom = this.contentParser.parse(content, syntax); |
61 |
2 |
executeContent(xdom, macroContext); |
62 |
1 |
return xdom; |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
65 |
23 |
@Override... |
66 |
|
public XDOM execute(String content, Syntax syntax, EntityReference source, MacroTransformationContext macroContext) |
67 |
|
throws ParseException, MissingParserException, ContentExecutorException |
68 |
|
{ |
69 |
23 |
XDOM xdom = this.contentParser.parse(content, syntax, source); |
70 |
23 |
executeContent(xdom, macroContext); |
71 |
23 |
return xdom; |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
74 |
25 |
private void executeContent(XDOM xdom, MacroTransformationContext macroContext) throws ContentExecutorException... |
75 |
|
{ |
76 |
25 |
try { |
77 |
25 |
this.macroTransformation.transform(xdom, macroContext.getTransformationContext()); |
78 |
|
} catch (TransformationException e) { |
79 |
1 |
throw new ContentExecutorException("Failed to execute content", e); |
80 |
|
} |
81 |
|
} |
82 |
|
} |