diff --git a/pluto-server/pom.xml b/pluto-server/pom.xml index b53b6870daba2d1164e2475abed060db8be757d7..7d057e5fd0a5a197d888785833a46524800d2272 100644 --- a/pluto-server/pom.xml +++ b/pluto-server/pom.xml @@ -28,11 +28,13 @@ <spring-admin.version>2.3.1</spring-admin.version> <commons-io.version>2.8.0</commons-io.version> - + <spring-boot.build-image.imageName>docker.ozg-sh.de/pluto:build-latest</spring-boot.build-image.imageName> <zip.version>2.7.0</zip.version> <jsoup.version>1.13.1</jsoup.version> + + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> @@ -121,9 +123,9 @@ <version>${zip.version}</version> </dependency> <dependency> - <groupId>org.jsoup</groupId> - <artifactId>jsoup</artifactId> - <version>${jsoup.version}</version> + <groupId>org.jsoup</groupId> + <artifactId>jsoup</artifactId> + <version>${jsoup.version}</version> </dependency> <!-- Dev --> @@ -263,16 +265,16 @@ <compilerArg> -Amapstruct.unmappedTargetPolicy=IGNORE </compilerArg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> - <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> + <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg> </compilerArgs> </configuration> </plugin> diff --git a/pluto-server/run_local.sh b/pluto-server/run_local.sh index 63a0f5abcbe20667ba33f29fd23503a312c7afe1..5b9fae1909baad9da60b0fe4551901a16f9d8817 100755 --- a/pluto-server/run_local.sh +++ b/pluto-server/run_local.sh @@ -1 +1 @@ -mvn spring-boot:run -Dspring-boot.run.profiles=local +./mvnw spring-boot:run -Dspring-boot.run.profiles=local diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/BeansConfig.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/BeansConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..ca2edf0a0bb7c556734e7e9968bf5e1c8ef8e948 --- /dev/null +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/BeansConfig.java @@ -0,0 +1,17 @@ +package de.itvsh.ozg.pluto; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; + +@Configuration +public class BeansConfig { + + @Bean + public FreeMarkerConfigurer freeMarkerConfigurer() { + FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); + freeMarkerConfigurer.setTemplateLoaderPath("classpath:/templates"); + freeMarkerConfigurer.setDefaultEncoding("UTF-8"); + return freeMarkerConfigurer; + } +} diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/vorgang/redirect/ForwardingService.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/vorgang/redirect/ForwardingService.java index 78258fc279e4293c99ae8a2a031b011865f7dd4d..c294467e11d3fd446741d3792d62e8b0f6673c01 100644 --- a/pluto-server/src/main/java/de/itvsh/ozg/pluto/vorgang/redirect/ForwardingService.java +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/vorgang/redirect/ForwardingService.java @@ -1,8 +1,7 @@ package de.itvsh.ozg.pluto.vorgang.redirect; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; +import java.io.StringWriter; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.HashMap; @@ -18,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.util.MimeTypeUtils; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import de.itvsh.ozg.mail.email.MailSendRequest; import de.itvsh.ozg.mail.email.MailSendRequest.MailAttachment; @@ -28,7 +28,6 @@ import de.itvsh.ozg.pluto.common.util.ForwardingLandesnetzInfoService; import de.itvsh.ozg.pluto.vorgang.Vorgang; import de.itvsh.ozg.pluto.vorgang.VorgangService; import de.itvsh.ozg.pluto.vorgang.redirect.Forwarding.Status; -import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; @@ -62,7 +61,7 @@ public class ForwardingService { private ForwardingRepository repository; @Autowired - private Configuration freemarkerCfg; + private FreeMarkerConfigurer freemarkerCfg; @Autowired private MailService emailService; @@ -225,9 +224,12 @@ public class ForwardingService { } private String fillTemplate(String templateName, Object dataModel) { - try (var outStream = new ByteArrayOutputStream(); var writer = new OutputStreamWriter(outStream)) { - getTemplate(templateName).process(dataModel, writer); - return new String(outStream.toByteArray()); + try { + Template template = getTemplate(templateName); + StringWriter stringWriter = new StringWriter(); + template.process(dataModel, stringWriter); + return stringWriter.toString(); + } catch (IOException | TemplateException e) { throw new TechnicalException("Error filling mail template", e); } @@ -235,7 +237,7 @@ public class ForwardingService { Template getTemplate(String templateName) { try { - return freemarkerCfg.getTemplate(templateName); + return freemarkerCfg.getConfiguration().getTemplate(templateName); } catch (IOException e) { throw new TechnicalException("Error loading mail template", e); }