Skip to content
Snippets Groups Projects
Commit 6904198b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

error handling ehen there is an issue with mesh data

parent 626ae33c
No related branches found
No related tags found
1 merge request!5Frontend refactor
......@@ -20,7 +20,7 @@ import org.w3c.dom.Node;
* type of the object to serialize
*/
public class XmlSerializer<T> {
/**
* Class of the object that DAO works on.
*/
......@@ -93,6 +93,8 @@ public class XmlSerializer<T> {
return (T) jaxbUnmarshaller.unmarshal(node);
} catch (JAXBException e) {
throw new SerializationException(e);
} catch (Exception e) { //the library can throw NPE sometimes...
throw new SerializationException(e);
}
}
......
......@@ -2,6 +2,9 @@ package lcsb.mapviewer.annotation.services;
import java.io.IOException;
import javax.sql.rowset.serial.SerialException;
import org.apache.commons.lang3.SerializationException;
import org.apache.log4j.Logger;
import org.w3c.dom.Node;
......@@ -100,16 +103,22 @@ public class MeSHParser extends CachableInterface implements IExternalService {
String id = getIdentifier(meshID);
Node meshNode = super.getCacheNode(id);
if (meshNode != null && meshNode.hasChildNodes()) {
mesh = meshSerializer.xmlToObject(meshNode);
} else {
try {
mesh = meshSerializer.xmlToObject(meshNode);
} catch (SerializationException e) {
logger.warn("Problem with processing cached info about mesh: " + meshID);
mesh = null;
}
}
if (mesh == null) {
try {
mesh = getMeSHByIdFromDB(meshID);
} catch (IOException e) {
throw new AnnotatorException("Problem with accessing MeSH database", e);
}
if (mesh != null) {
super.setCacheValue(id, this.meshSerializer.objectToString(mesh));
}
}
if (mesh != null) {
super.setCacheValue(id, this.meshSerializer.objectToString(mesh));
}
return mesh;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment