diff --git a/src/main/java/fr/insee/rmes/config/PropertiesLoading.java b/src/main/java/fr/insee/rmes/config/PropertiesLoading.java index 545fe7be..ee73e867 100644 --- a/src/main/java/fr/insee/rmes/config/PropertiesLoading.java +++ b/src/main/java/fr/insee/rmes/config/PropertiesLoading.java @@ -11,24 +11,30 @@ public Properties getProperties() throws IOException { Properties props = new Properties(); props.load(this.getClass().getClassLoader().getResourceAsStream("api-stable.properties")); props.load(this.getClass().getClassLoader().getResourceAsStream("rmes-api.properties")); - this.loadIfExists(props, "rmes-api.properties"); - this.loadIfExists(props, "rmeswnci.properties"); - this.loadIfExists(props, "rmeswncz.properties"); - this.loadIfExists(props, "rmeswncd.properties"); - this.loadIfExists(props, "production.properties"); + this.loadFromCatalinaIfExists(props, "rmes-api.properties"); + this.loadFromCatalinaIfExists(props, "rmeswnci.properties"); + this.loadFromCatalinaIfExists(props, "rmeswncz.properties"); + this.loadFromCatalinaIfExists(props, "rmeswncd.properties"); + this.loadFromCatalinaIfExists(props, "production.properties"); + this.loadFromFileIfExist(props, "/conf/rmes-api.properties"); return props; } /* * load properties on catalina base */ - private Properties loadIfExists(Properties props, String filename) throws IOException { - File f; - f = new File(String.format("%s/webapps/%s", System.getProperty("catalina.base"), filename)); - if (f.exists() && !f.isDirectory()) { - try (FileReader r = new FileReader(f);){ - props.load(r); - return props; + private Properties loadFromCatalinaIfExists (Properties props, String filename) throws IOException { + return loadFromFileIfExist(props, String.format("%s/webapps/%s", System.getProperty("catalina.base"), filename)); + } + + /* + * Load properties from ConfigMap mounted path and return the modified properties + */ + private Properties loadFromFileIfExist(Properties props, String absolutePathToFile) throws IOException { + File file = new File(absolutePathToFile); + if (file.exists() && !file.isDirectory()) { + try (FileReader reader = new FileReader(file)) { + props.load(reader); } } return props;