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