Commit 4a71ee18 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

sbgn2String doens't create temporary file

parent 3a8d4e6f
......@@ -4,7 +4,6 @@ import java.io.*;
import javax.xml.bind.JAXBException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.core.LogEvent;
import org.sbgn.SbgnUtil;
......@@ -51,21 +50,20 @@ public class SbgnmlXmlConverter extends Converter {
MinervaLoggerAppender.unregisterLogEventStorage(appender);
}
try {
File tempFile = File.createTempFile("sbgnmlExportTempFile", ".tmp");
SbgnUtil.writeToFile(exportedData, tempFile);
try (FileInputStream inputStream = new FileInputStream(tempFile)) {
String xml = IOUtils.toString(inputStream, "UTF-8");
if (notes.length() > 0) {
int position = xml.indexOf("<map language");
if (position < 0) {
throw new ConverterException("problematic output sbgn. Cannot find map tag");
}
String notesNode = "<notes><html:body xmlns:html=\"http://www.w3.org/1999/xhtml\">" +
StringEscapeUtils.escapeXml10(notes.toString()) + "\n</html:body></notes> ";
xml = xml.substring(0, position) + notesNode + xml.substring(position);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SbgnUtil.writeTo(exportedData, baos);
String xml = new String(baos.toByteArray(), "UTF-8");
if (notes.length() > 0) {
int position = xml.indexOf("<map language");
if (position < 0) {
throw new ConverterException("problematic output sbgn. Cannot find map tag");
}
return xml;
String notesNode = "<notes><html:body xmlns:html=\"http://www.w3.org/1999/xhtml\">" +
StringEscapeUtils.escapeXml10(notes.toString()) + "\n</html:body></notes> ";
xml = xml.substring(0, position) + notesNode + xml.substring(position);
}
return xml;
} catch (IOException | JAXBException e) {
throw new ConverterException(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