| 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; |
| 21 |
|
|
| 22 |
|
import javax.inject.Inject; |
| 23 |
|
import javax.inject.Named; |
| 24 |
|
import javax.inject.Singleton; |
| 25 |
|
|
| 26 |
|
import org.apache.commons.lang3.StringUtils; |
| 27 |
|
import org.slf4j.Logger; |
| 28 |
|
import org.xwiki.component.annotation.Component; |
| 29 |
|
import org.xwiki.configuration.ConfigurationSource; |
| 30 |
|
import org.xwiki.rendering.parser.ParseException; |
| 31 |
|
import org.xwiki.rendering.syntax.Syntax; |
| 32 |
|
import org.xwiki.rendering.syntax.SyntaxFactory; |
| 33 |
|
|
| 34 |
|
import com.xpn.xwiki.CoreConfiguration; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@version |
| 40 |
|
@since |
| 41 |
|
|
| 42 |
|
@Component |
| 43 |
|
@Singleton |
| |
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 44 |
|
public class DefaultCoreConfiguration implements CoreConfiguration |
| 45 |
|
{ |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
private static final String PREFIX = "core."; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@Inject |
| 55 |
|
@Named("all") |
| 56 |
|
private ConfigurationSource configuration; |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@since |
| 62 |
|
|
| 63 |
|
@Inject |
| 64 |
|
private SyntaxFactory syntaxFactory; |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
@link |
| 68 |
|
|
| 69 |
|
@Inject |
| 70 |
|
@Named("xwikiproperties") |
| 71 |
|
private ConfigurationSource xwikiPropertiesConfiguration; |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
@Inject |
| 77 |
|
private Logger logger; |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
@see |
| 81 |
|
@since |
| 82 |
|
|
| |
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 83 |
16996 |
@Override... |
| 84 |
|
public Syntax getDefaultDocumentSyntax() |
| 85 |
|
{ |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
16995 |
String key = PREFIX + "defaultDocumentSyntax"; |
| 91 |
16995 |
String syntaxId = this.configuration.getProperty(key, String.class); |
| 92 |
|
|
| 93 |
16995 |
if (StringUtils.isEmpty(syntaxId)) { |
| 94 |
16992 |
syntaxId = this.xwikiPropertiesConfiguration.getProperty(key, Syntax.XWIKI_2_1.toIdString()); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
16994 |
Syntax syntax; |
| 99 |
16996 |
try { |
| 100 |
16996 |
syntax = this.syntaxFactory.createSyntaxFromIdString(syntaxId); |
| 101 |
|
} catch (ParseException e) { |
| 102 |
0 |
this.logger.warn( |
| 103 |
|
"Invalid default document Syntax [" + syntaxId + "], defaulting to [" + Syntax.XWIKI_2_1.toIdString() |
| 104 |
|
+ "] instead", e); |
| 105 |
0 |
syntax = Syntax.XWIKI_2_1; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
16990 |
return syntax; |
| 109 |
|
} |
| 110 |
|
} |