Commit c401bfdf authored by Marcel's avatar Marcel
Browse files

Improve charset compatibility with SongBeamer

parent ac1724b2
Pipeline #127219312 passed with stage
in 3 minutes and 32 seconds
......@@ -25,3 +25,4 @@
/.nb-gradle/
application-dev.yml
/tmp
......@@ -5,7 +5,7 @@
<groupId>de.apis-stuttgart</groupId>
<artifactId>churchtools-to-songbeamer</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>churchtools-to-songbeamer</name>
......@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<version>2.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
......
......@@ -30,6 +30,9 @@ public class AgendaConverterService {
@Autowired
protected SbControllerService sbControllerService;
@Autowired
protected FileWriterService fileWriterService;
protected static String LINE_SEPARATOR = System.getProperty("line.separator");
......@@ -68,7 +71,7 @@ public class AgendaConverterService {
Files.createDirectories(sbAgendaFile.getParent());
}
Files.write(sbAgendaFile, sbAgenda.toString().getBytes(StandardCharsets.ISO_8859_1));
fileWriterService.write(sbAgendaFile, sbAgenda.toString(), true);
log.info("Songbeamer agenda was written to " + sbAgendaFile.toAbsolutePath().toString());
......
......@@ -43,6 +43,9 @@ public class CtSongService {
@Autowired
protected SongbeamerConfig songbeamerConfig;
@Autowired
protected FileWriterService fileWriterService;
protected RestTemplate restTemplate = new RestTemplate();
protected static Collection<CtSong> allSongs;
......@@ -107,7 +110,7 @@ public class CtSongService {
String song = response.getBody();
Files.write(target, song.getBytes(StandardCharsets.ISO_8859_1));
fileWriterService.write(target, song);
log.debug("Song: " + song);
......
package de.apisstuttgart.churchtoolstosongbeamer.service;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
@Service
@CommonsLog
public class FileWriterService {
public void write(Path path, String content) throws IOException {
write(path, content, false);
}
public void write(Path path, String content, boolean writeUTF8BOM) throws IOException {
if (writeUTF8BOM) {
content = "\uFEFF" + content;
}
try {
Files.write(path, content.getBytes(Charset.forName("UTF-8")));
} catch (IOException e) {
log.error("Could not write content to " + path);
throw e;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment