Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
4a71ee18
Commit
4a71ee18
authored
Nov 12, 2019
by
Piotr Gawron
Browse files
sbgn2String doens't create temporary file
parent
3a8d4e6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlConverter.java
View file @
4a71ee18
...
@@ -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
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment