Skip to content

Commit 3f79599

Browse files
committed
Read theme data as resource when SpringBoot is enabled
Read application.gam and connection.gam when Springboot ir run as jar. Issue: 103655
1 parent c343a85 commit 3f79599

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

common/src/main/java/com/genexus/util/ThemeHelper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.genexus.util;
22

33
import java.io.File;
4+
import java.nio.charset.StandardCharsets;
45
import java.util.HashMap;
56
import java.util.Map;
67
import java.util.Collections;
@@ -11,6 +12,7 @@
1112

1213
import com.genexus.CommonUtil;
1314
import com.genexus.common.interfaces.SpecificImplementation;
15+
import org.springframework.core.io.ClassPathResource;
1416

1517
public class ThemeHelper
1618
{
@@ -34,7 +36,11 @@ private static ThemeData getThemeData(String themeName)
3436
ThemeData themeData;
3537
try
3638
{
37-
String json = SpecificImplementation.GXutil.readFileToString(themesJsonFile, CommonUtil.normalizeEncodingName("UTF-8"));
39+
String json;
40+
if (com.genexus.ApplicationContext.getInstance().isSpringBootApp())
41+
json = new ClassPathResource("themes/" + themeName + ".json").getContentAsString(StandardCharsets.UTF_8);
42+
else
43+
json = SpecificImplementation.GXutil.readFileToString(themesJsonFile, CommonUtil.normalizeEncodingName("UTF-8"));
3844
themeData = ThemeData.fromJson(json);
3945
}
4046
catch (Exception ex)

common/src/main/java/com/genexus/xml/XMLReader.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,23 +772,28 @@ public void open(String url)
772772
reset();
773773
try
774774
{
775-
File xmlFile = new File(url);
775+
InputStream fileInputStream = null;
776776
if (ApplicationContext.getInstance().isSpringBootApp())
777777
{
778778
ClassPathResource resource = new ClassPathResource(url);
779779
if (resource.exists())
780-
xmlFile = resource.getFile();
780+
fileInputStream = resource.getInputStream();
781781
else
782782
{
783783
if (url.startsWith(ApplicationContext.getInstance().getServletEngineDefaultPath()))
784784
{
785785
resource = new ClassPathResource(url.replace(ApplicationContext.getInstance().getServletEngineDefaultPath(), ""));
786786
if (resource.exists())
787-
xmlFile = resource.getFile();
787+
fileInputStream = resource.getInputStream();
788788
}
789789
}
790790
}
791-
inputSource = new XMLInputSource(null, url, null, new FileInputStream(xmlFile), null);
791+
else
792+
{
793+
File xmlFile = new File(url);
794+
fileInputStream = new FileInputStream(xmlFile);
795+
}
796+
inputSource = new XMLInputSource(null, url, null, fileInputStream, null);
792797
if (documentEncoding.length() > 0)
793798
inputSource.setEncoding(CommonUtil.normalizeEncodingName(documentEncoding));
794799
parserConfiguration.setInputSource(inputSource);

0 commit comments

Comments
 (0)