Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
28e7bd3b
Commit
28e7bd3b
authored
Jun 05, 2020
by
Piotr Gawron
Browse files
files with BOM were not processed properly
parent
ed20b798
Changes
5
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
28e7bd3b
...
...
@@ -4,6 +4,7 @@ minerva (15.0.0~beta.5) unstable; urgency=medium
(#
1262
)
*
Bug
fix
:
there
is
a
bug
in
PathVisio
that
breaks
short
segments
being
the
end
of
catalist
therefore
short
segments
are
removed
from
export
(#
1263
)
*
Bug
fix
:
conversion
of
file
containing
BOM
did
not
work
(#
1264
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Tue
,
2
Jun
2020
16
:
00
:
00
+
0200
...
...
rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertController.java
View file @
28e7bd3b
...
...
@@ -35,7 +35,7 @@ public class ConvertController extends BaseController {
@PostMapping
(
value
=
"/{fromFormat}:{toFormat}"
,
produces
=
MediaType
.
APPLICATION_XML_VALUE
)
public
String
convertInput
(
@PathVariable
(
value
=
"fromFormat"
)
String
fromFormat
,
@PathVariable
(
value
=
"toFormat"
)
String
toFormat
,
@RequestBody
String
body
)
@RequestBody
byte
[]
body
)
throws
IOException
,
QueryException
,
SBMLException
,
InvalidInputDataExecption
,
InconsistentModelException
,
ConverterException
{
return
convertController
.
convert
(
fromFormat
,
toFormat
,
body
);
...
...
@@ -45,7 +45,7 @@ public class ConvertController extends BaseController {
public
@ResponseBody
ResponseEntity
<
byte
[]>
convertInputToImage
(
@PathVariable
(
value
=
"fromFormat"
)
String
fromFormat
,
@PathVariable
(
value
=
"toFormat"
)
String
toFormat
,
@RequestBody
String
body
)
@RequestBody
byte
[]
body
)
throws
IOException
,
QueryException
,
SBMLException
,
InvalidInputDataExecption
,
ConverterException
,
DrawingException
{
ByteArrayOutputStream
os
=
convertController
.
converToImage
(
fromFormat
,
toFormat
,
body
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/convert/ConvertRestImpl.java
View file @
28e7bd3b
...
...
@@ -35,7 +35,7 @@ public class ConvertRestImpl extends BaseRestImpl {
private
Logger
logger
=
LogManager
.
getLogger
(
ConvertRestImpl
.
class
);
public
String
convert
(
String
fromFormat
,
String
toFormat
,
String
input
)
public
String
convert
(
String
fromFormat
,
String
toFormat
,
byte
[]
input
)
throws
InvalidInputDataExecption
,
SBMLException
,
InconsistentModelException
,
IOException
,
ConverterException
,
QueryException
{
ConverterParams
params
=
createConvertParams
(
input
);
...
...
@@ -57,7 +57,7 @@ public class ConvertRestImpl extends BaseRestImpl {
return
IOUtils
.
toString
(
exporter
.
model2InputStream
(
model
),
StandardCharsets
.
UTF_8
);
}
public
ByteArrayOutputStream
converToImage
(
String
fromFormat
,
String
toFormat
,
String
input
,
public
ByteArrayOutputStream
converToImage
(
String
fromFormat
,
String
toFormat
,
byte
[]
input
,
Double
targetWidth
,
Double
targetHeight
)
throws
InvalidInputDataExecption
,
SBMLException
,
IOException
,
ConverterException
,
DrawingException
,
QueryException
{
...
...
@@ -69,7 +69,7 @@ public class ConvertRestImpl extends BaseRestImpl {
return
os
;
}
public
ByteArrayOutputStream
converToImage
(
String
fromFormat
,
String
toFormat
,
String
input
)
public
ByteArrayOutputStream
converToImage
(
String
fromFormat
,
String
toFormat
,
byte
[]
input
)
throws
IOException
,
DrawingException
,
QueryException
{
try
{
return
converToImage
(
fromFormat
,
toFormat
,
input
,
0.0
,
0.0
);
...
...
@@ -246,9 +246,9 @@ public class ConvertRestImpl extends BaseRestImpl {
}
private
ConverterParams
createConvertParams
(
String
input
)
{
private
ConverterParams
createConvertParams
(
byte
[]
input
)
{
ConverterParams
params
=
new
ConverterParams
();
InputStream
is
=
new
ByteArrayInputStream
(
input
.
getBytes
()
);
InputStream
is
=
new
ByteArrayInputStream
(
input
);
params
.
inputStream
(
is
);
...
...
web/src/test/java/lcsb/mapviewer/web/ConvertControllerIntegrationTest.java
View file @
28e7bd3b
...
...
@@ -4,10 +4,11 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.*
;
import
java.nio.file.Files
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.http.MediaType
;
...
...
@@ -22,6 +23,8 @@ import lcsb.mapviewer.model.map.species.Element;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
ConvertControllerIntegrationTest
extends
ControllerIntegrationTest
{
Logger
logger
=
LogManager
.
getLogger
();
@Test
public
void
testConvertInvalidFile
()
throws
Exception
{
String
body
=
"invalid content"
;
...
...
@@ -33,6 +36,23 @@ public class ConvertControllerIntegrationTest extends ControllerIntegrationTest
.
andExpect
(
status
().
isBadRequest
());
}
@Test
public
void
convertWithBOM
()
throws
Exception
{
FileReader
fr
=
new
FileReader
(
new
File
(
"src/test/resources/SBGN_with_BOM.sbgn"
));
BufferedReader
br
=
new
BufferedReader
(
fr
);
StringBuilder
tmp
=
new
StringBuilder
();
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
tmp
.
append
(
line
+
System
.
getProperty
(
"line.separator"
));
}
RequestBuilder
request
=
post
(
"/convert/image/SBGN-ML:svg"
)
.
content
(
tmp
.
toString
().
getBytes
(
"UTF-8"
)).
characterEncoding
(
"UTF-8"
);
br
.
close
();
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
is2xxSuccessful
());
}
@Test
public
void
testConvertInvalidMapFormat
()
throws
Exception
{
String
body
=
"invalid content"
;
...
...
web/src/test/resources/SBGN_with_BOM.sbgn
0 → 100644
View file @
28e7bd3b
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<sbgn
xmlns=
"http://sbgn.org/libsbgn/0.2"
>
<map
language=
"process description"
>
<glyph
id=
"nwtN_74c3dbfb-02b1-4e28-9d43-0cae011acf2a"
class=
"simple chemical"
>
<label
text=
"el2"
/>
<bbox
x=
"866.8349084372152"
y=
"296.1973717584831"
w=
"136.82486912403263"
h=
"73.70108282346791"
/>
</glyph>
<glyph
id=
"nwtN_dea3dbde-02e4-40f9-8c27-963282d20de2"
class=
"process"
>
<bbox
x=
"1126.3443211534611"
y=
"311.68061284687263"
w=
"34.22866874880496"
h=
"34.22866874880496"
/>
<port
id=
"nwtN_dea3dbde-02e4-40f9-8c27-963282d20de2.1"
x=
"1119.4985874037002"
y=
"328.7949472212751"
/>
<port
id=
"nwtN_dea3dbde-02e4-40f9-8c27-963282d20de2.2"
x=
"1167.418723652027"
y=
"328.7949472212751"
/>
</glyph>
<glyph
id=
"nwtN_ffaa36d2-067e-4eaa-81b0-8bf83d7e8e81"
class=
"macromolecule"
>
<label
text=
"el1"
/>
<bbox
x=
"1335.0238493448692"
y=
"304.694418205774"
w=
"117.05419146397195"
h=
"78.55675869274216"
/>
</glyph>
<glyph
id=
"nwtN_c9c80149-ba98-44fe-a40c-e2ebb098d21a"
class=
"omitted process"
>
<bbox
x=
"1132.2447485580458"
y=
"207.098961267922"
w=
"39.43117860874146"
h=
"39.43117860874146"
/>
<port
id=
"nwtN_c9c80149-ba98-44fe-a40c-e2ebb098d21a.1"
x=
"1124.3585128362975"
y=
"226.81455057229272"
/>
<port
id=
"nwtN_c9c80149-ba98-44fe-a40c-e2ebb098d21a.2"
x=
"1179.5621628885356"
y=
"226.81455057229272"
/>
</glyph>
<arc
id=
"nwtE_bce73d75-967b-4473-9028-bfc10d8af4eb"
class=
"consumption"
source=
"nwtN_74c3dbfb-02b1-4e28-9d43-0cae011acf2a"
target=
"nwtN_dea3dbde-02e4-40f9-8c27-963282d20de2.1"
>
<start
x=
"1004.2359525482459"
y=
"331.6387380215975"
/>
<end
x=
"1118.8735874037002"
y=
"328.7949472212751"
/>
</arc>
<arc
id=
"nwtE_d0911b94-b9b8-4115-b475-4d43894de402"
class=
"production"
source=
"nwtN_dea3dbde-02e4-40f9-8c27-963282d20de2.2"
target=
"nwtN_ffaa36d2-067e-4eaa-81b0-8bf83d7e8e81"
>
<start
x=
"1168.043723652027"
y=
"328.7949472212751"
/>
<end
x=
"1331.2795884250613"
y=
"340.1936113450629"
/>
</arc>
</map>
</sbgn>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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