Load various resources from classpath instead of an actual path on Stagging and Production
This commit is contained in:
parent
a8015064a8
commit
ddd0b60d37
|
@ -74,16 +74,25 @@ public class ProductionConfigLoader implements ConfigLoader {
|
||||||
String filePath = environment.getProperty("configuration.rda");
|
String filePath = environment.getProperty("configuration.rda");
|
||||||
BufferedReader reader;
|
BufferedReader reader;
|
||||||
List<String> rdaList = new LinkedList<>();
|
List<String> rdaList = new LinkedList<>();
|
||||||
try {
|
for (int i = 0; i < 2; i++) {
|
||||||
reader = new BufferedReader(new FileReader(filePath));
|
try {
|
||||||
String line = reader.readLine();
|
if (i == 0) {
|
||||||
while (line != null) {
|
reader = new BufferedReader(new FileReader(filePath));
|
||||||
rdaList.add(line);
|
} else {
|
||||||
line = reader.readLine();
|
reader = new BufferedReader(new FileReader(getClass().getClassLoader().getResource(filePath).getFile()));
|
||||||
|
}
|
||||||
|
String line = reader.readLine();
|
||||||
|
while (line != null) {
|
||||||
|
rdaList.add(line);
|
||||||
|
line = reader.readLine();
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
break;
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (i == 1) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rdaProperties = rdaList;
|
rdaProperties = rdaList;
|
||||||
|
@ -92,16 +101,25 @@ public class ProductionConfigLoader implements ConfigLoader {
|
||||||
private void setDocument() {
|
private void setDocument() {
|
||||||
String filePath = environment.getProperty("configuration.h2020template");
|
String filePath = environment.getProperty("configuration.h2020template");
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
for (int i = 0; i < 2; i++) {
|
||||||
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
|
||||||
this.document = new XWPFDocument(is);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
} finally {
|
|
||||||
try {
|
try {
|
||||||
if (is != null) is.close();
|
if (i == 0) {
|
||||||
|
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
||||||
|
} else {
|
||||||
|
is = getClass().getClassLoader().getResource(filePath).openStream();
|
||||||
|
}
|
||||||
|
this.document = new XWPFDocument(is);
|
||||||
|
is.close();
|
||||||
|
is = null;
|
||||||
|
break;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
|
logger.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (is != null) is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn("Warning: Could not close a stream after reading from file: " + filePath, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,11 +131,11 @@ public class ProductionConfigLoader implements ConfigLoader {
|
||||||
File tempFile = new File(filePath);
|
File tempFile = new File(filePath);
|
||||||
if (tempFile.exists()) {
|
if (tempFile.exists()) {
|
||||||
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
this.configurableProviders = objectMapper.readValue(is, ConfigurableProviders.class);
|
|
||||||
} else {
|
} else {
|
||||||
this.configurableProviders = new ConfigurableProviders();
|
is = getClass().getClassLoader().getResource(filePath).openStream();
|
||||||
}
|
}
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
this.configurableProviders = objectMapper.readValue(is, ConfigurableProviders.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -179,6 +197,7 @@ public class ProductionConfigLoader implements ConfigLoader {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
Document doc;
|
Document doc;
|
||||||
try {
|
try {
|
||||||
|
System.out.println(filePath);
|
||||||
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
is = new URL(Paths.get(filePath).toUri().toURL().toString()).openStream();
|
||||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
|
|
|
@ -16,9 +16,9 @@ pdf.converter.url=http://docsbox-web/
|
||||||
|
|
||||||
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
|
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
|
||||||
configuration.externalUrls=externalUrls/ExternalUrls.xml
|
configuration.externalUrls=externalUrls/ExternalUrls.xml
|
||||||
configuration.rda=/tmp/RDACommonStandards.txt
|
configuration.rda=RDACommonStandards.txt
|
||||||
configuration.h2020template=documents/h2020.docx
|
configuration.h2020template=documents/h2020.docx
|
||||||
configuration.configurable_login_providers=/tmp/ConfigurableLoginProviders.json
|
configuration.configurable_login_providers=ConfigurableLoginProviders.json
|
||||||
|
|
||||||
####################SPRING MAIL CONFIGURATIONS#################
|
####################SPRING MAIL CONFIGURATIONS#################
|
||||||
spring.mail.default-encoding=UTF-8
|
spring.mail.default-encoding=UTF-8
|
||||||
|
|
|
@ -16,9 +16,9 @@ pdf.converter.url=http://docsbox-web/
|
||||||
|
|
||||||
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
|
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
|
||||||
configuration.externalUrls=externalUrls/ExternalUrls.xml
|
configuration.externalUrls=externalUrls/ExternalUrls.xml
|
||||||
configuration.rda=/tmp/RDACommonStandards.txt
|
configuration.rda=RDACommonStandards.txt
|
||||||
configuration.h2020template=documents/h2020.docx
|
configuration.h2020template=documents/h2020.docx
|
||||||
configuration.configurable_login_providers=/tmp/ConfigurableLoginProviders.json
|
configuration.configurable_login_providers=ConfigurableLoginProviders.json
|
||||||
|
|
||||||
####################INVITATION MAIL CONFIGURATIONS##############
|
####################INVITATION MAIL CONFIGURATIONS##############
|
||||||
####################GENERIC MAIL CONFIGURATIONS#################
|
####################GENERIC MAIL CONFIGURATIONS#################
|
||||||
|
|
Loading…
Reference in New Issue