Skip to content

Commit

Permalink
Added http config server condition while fetching template json
Browse files Browse the repository at this point in the history
Signed-off-by: Piyush7034 <[email protected]>
  • Loading branch information
Piyush7034 committed Oct 21, 2024
1 parent a821349 commit 6b57871
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ public class TemplateConfig implements CommandLineRunner {
public void run(String... args) throws Exception {
String svgTemplateContent = "";
List<Object> svgTemplateMap;
Resource resource = new ClassPathResource(svgTemplateJson);
try {
svgTemplateContent = (Files.readString(resource.getFile().toPath()));
} catch (IOException e) {
log.error("Missing local json file for referring svg templates", e);

if(svgTemplateJson.startsWith("http")) {
svgTemplateContent = restTemplate.getForObject(svgTemplateJson, String.class);
} else {
Resource resource = new ClassPathResource(svgTemplateJson);
try {
svgTemplateContent = (Files.readString(resource.getFile().toPath()));
} catch (IOException e) {
log.error("Missing local json file for referring svg templates", e);
}
}


if(!svgTemplateContent.isEmpty()) {
try {
svgTemplateMap = objectMapper.readValue(svgTemplateContent, List.class);
Expand Down

0 comments on commit 6b57871

Please sign in to comment.