Affected Issue(s): #606 (#612)

What this commit has achieved:
1. Externalized location of "mdm-rules.json" in the `AppProperties`
2. More info about the `ResourceLoader` interface is available at
https://docs.spring.io/spring-framework/reference/core/resources.html#resources-resourceloader
This commit is contained in:
Levi
2023-12-05 03:10:21 +07:00
committed by GitHub
parent 41a537efb2
commit 0be636c169
3 changed files with 12 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ public class AppProperties {
private Boolean ips_enabled = false;
private Boolean openapi_enabled = false;
private Boolean mdm_enabled = false;
private String mdm_rules_json_location = "mdm-rules.json";
private boolean advanced_lucene_indexing = false;
private boolean enable_index_of_type = false;
private Boolean allow_cascading_deletes = false;
@@ -191,7 +192,15 @@ public class AppProperties {
this.mdm_enabled = mdm_enabled;
}
public Cors getCors() {
public String getMdm_rules_json_location() {
return mdm_rules_json_location;
}
public void setMdm_rules_json_location(String mdm_rules_json_location) {
this.mdm_rules_json_location = mdm_rules_json_location;
}
public Cors getCors() {
return cors;
}

View File

@@ -28,7 +28,7 @@ public class MdmConfig {
IMdmSettings mdmSettings(@Autowired MdmRuleValidator theMdmRuleValidator, AppProperties appProperties)
throws IOException {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("mdm-rules.json");
Resource resource = resourceLoader.getResource(appProperties.getMdm_rules_json_location());
String json = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
return new MdmSettings(theMdmRuleValidator)
.setEnabled(appProperties.getMdm_enabled())