diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java index 84d2a479626c345beca3fd0d74f7ddbaacee88d5..e7882624e92231c63bf63f9ba5cb4cce581d5c45 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MeSHParser.java @@ -109,6 +109,9 @@ public class MeSHParser extends CachableInterface implements IExternalService { if (meshID == null || meshID.getResource() == null) { throw new InvalidArgumentException("mesh cannot be null "); } + if (meshID.getResource().indexOf(" ") >= 0) { + return null; + } MeSH mesh = null; // look for Mesh in the cache @@ -321,7 +324,7 @@ public class MeSHParser extends CachableInterface implements IExternalService { ArrayList<?> hitsList = (ArrayList<?>) hits.get("hits"); for (Object object : hitsList) { StringMap<?> hit = (StringMap<?>) object; - String id = (String) hit.get("_id"); + String id = (String) hit.get("_id"); result.add(new MiriamData(MiriamType.MESH_2012, id)); } return result; diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java index 8fb197d385fefbc71cb198e72db6a690aaeefb12..720bc0ebfcb9b47fc7c438691b5bb21e4bbfd505 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MeSHParserTest.java @@ -118,6 +118,18 @@ public class MeSHParserTest extends AnnotationTestFunctions { } } + @Test + public void testIsValidWithSpace() throws Exception { + try { + MiriamData meshID = new MiriamData(MiriamType.MESH_2012, "some disease"); + assertFalse(meshParser.isValidMeshId(meshID)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testGetInvalidMesh() throws Exception { try {