Commit cf2b0525 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

error handling improved in serialization of mesh data

parent 85dd9930
......@@ -53,7 +53,7 @@ public class XmlSerializer<T> {
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbUnmarshaller = jaxbContext.createUnmarshaller();
} catch (JAXBException e) {
throw new SerializationException();
throw new SerializationException(e);
}
}
......@@ -73,6 +73,8 @@ public class XmlSerializer<T> {
jaxbMarshaller.marshal(object, sw);
} catch (JAXBException e) {
throw new SerializationException(e);
} catch (Exception e) {
throw new SerializationException(e);
}
return sw.toString();
}
......@@ -93,6 +95,8 @@ public class XmlSerializer<T> {
return (T) jaxbUnmarshaller.unmarshal(node);
} catch (JAXBException e) {
throw new SerializationException(e);
} catch (Exception e) {
throw new SerializationException(e);
}
}
......
......@@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.services;
import java.io.IOException;
import org.apache.commons.lang3.SerializationException;
import org.apache.log4j.Logger;
import org.w3c.dom.Node;
......@@ -100,16 +101,21 @@ 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 mesh data for: " + meshID);
}
}
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;
......
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