fixed config load

This commit is contained in:
Brian Long 2021-01-18 17:43:40 -05:00
parent d15b54796d
commit 340c7c6f30
2 changed files with 12 additions and 16 deletions

View File

@ -27,12 +27,13 @@ import org.commonmark.renderer.Renderer;
import org.commonmark.renderer.html.HtmlRenderer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
@Component(CommonmarkTransformer.ID)
@ConfigurationProperties(prefix = "transform.alfmarkdown.commonmark")
public class CommonmarkTransformer implements Transformer {
public static final String ID = "commonmark";
@ -41,11 +42,7 @@ public class CommonmarkTransformer implements Transformer {
private final List<String> classSearchPrefixes = Arrays.asList("", "org.commonmark.ext.{name}.", "org.commonmark.ext.gfm.{name}.");
private final Pattern extClassNamePattern = Pattern.compile("[\\.]?(([A-Za-z0-9]+)Extension|[A-Za-z0-9]+)$");
@Value("${transform.alfmarkdown.commonmark.defaultProfile}")
private String profile;
@Value("${transform.alfmarkdown.commonmark.defaultExtensions}")
private List<String> extensionClassNames;
private List<String> defaultExtensions;
@PostConstruct
public void init() throws Exception {
@ -104,8 +101,8 @@ public class CommonmarkTransformer implements Transformer {
private List<Extension> gatherExtensions(Map<String, String> transformOptions) {
// include default extensions
Set<String> extClassNames = new HashSet<>();
if (this.extensionClassNames != null)
extClassNames.addAll(this.extensionClassNames);
if (this.defaultExtensions != null)
extClassNames.addAll(this.defaultExtensions);
// include/exclude based on passed in extensions
String extClassNamesRaw = transformOptions.get(RequestParamConstants.EXT_CLASS_NAMES);

View File

@ -21,7 +21,7 @@ import org.alfresco.transform.exceptions.TransformException;
import org.alfresco.transformer.executors.Transformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
@ -35,6 +35,7 @@ import com.vladsch.flexmark.util.data.MutableDataSet;
import com.vladsch.flexmark.util.misc.Extension;
@Component(FlexmarkTransformer.ID)
@ConfigurationProperties(prefix = "transform.alfmarkdown.flexmark")
public class FlexmarkTransformer implements Transformer {
public static final String ID = "flexmark";
@ -43,11 +44,9 @@ public class FlexmarkTransformer implements Transformer {
private final List<String> classSearchPrefixes = Arrays.asList("", "com.vladsch.flexmark.ext.{name}.", "com.vladsch.flexmark.ext.");
private final Pattern extClassNamePattern = Pattern.compile("[\\.]?(([A-Za-z0-9]+)Extension|[A-Za-z0-9]+)$");
@Value("${transform.alfmarkdown.flexmark.defaultProfile}")
private String profile;
private String defaultProfile;
@Value("${transform.alfmarkdown.flexmark.defaultExtensions}")
private List<String> extensionClassNames;
private List<String> defaultExtensions;
@PostConstruct
public void init() throws Exception {
@ -76,7 +75,7 @@ public class FlexmarkTransformer implements Transformer {
if (!MediaType.TEXT_MARKDOWN_VALUE.equals(sourceMimetype))
throw new TransformException(HttpStatus.BAD_REQUEST.value(), "This transformer does not support source data of the '" + sourceMimetype + "' type");
String profile = transformOptions.getOrDefault(RequestParamConstants.PROFILE, this.profile);
String profile = transformOptions.getOrDefault(RequestParamConstants.PROFILE, this.defaultProfile);
MutableDataSet options = new MutableDataSet();
options.setFrom(ParserEmulationProfile.valueOf(profile.toUpperCase()));
@ -110,8 +109,8 @@ public class FlexmarkTransformer implements Transformer {
private List<Extension> gatherExtensions(Map<String, String> transformOptions) {
// include default extensions
Set<String> extClassNames = new HashSet<>();
if (this.extensionClassNames != null)
extClassNames.addAll(this.extensionClassNames);
if (this.defaultExtensions != null)
extClassNames.addAll(this.defaultExtensions);
// include/exclude based on passed in extensions
String extClassNamesRaw = transformOptions.get(RequestParamConstants.EXT_CLASS_NAMES);