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

error handling for problems with cache improved

parent 164a1642
No related branches found
No related tags found
1 merge request!11Resolve "Rest API should follow google guidlines"
...@@ -9,6 +9,7 @@ import java.util.Set; ...@@ -9,6 +9,7 @@ import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang3.SerializationException;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -474,8 +475,12 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi ...@@ -474,8 +475,12 @@ public class DrugbankHTMLParser extends DrugAnnotation implements IExternalServi
@Override @Override
public Drug findDrug(String drugName) throws DrugSearchException { public Drug findDrug(String drugName) throws DrugSearchException {
String query = DRUG_NAME_PREFIX + drugName; String query = DRUG_NAME_PREFIX + drugName;
Drug drug = null;
Drug drug = getDrugSerializer().xmlToObject(getCacheNode(query)); try {
drug = getDrugSerializer().xmlToObject(getCacheNode(query));
} catch (SerializationException e) {
logger.error("Problem with deserializing element by query: " + query);
}
if (drug != null) { if (drug != null) {
return drug; return drug;
} }
......
...@@ -210,7 +210,12 @@ public class XmlParser { ...@@ -210,7 +210,12 @@ public class XmlParser {
protected Document getXmlDocumentFromString(final String text) throws InvalidXmlSchemaException { protected Document getXmlDocumentFromString(final String text) throws InvalidXmlSchemaException {
InputSource is = new InputSource(); InputSource is = new InputSource();
is.setCharacterStream(new StringReader(text)); is.setCharacterStream(new StringReader(text));
return getXmlDocumentFromInputSource(is); try {
return getXmlDocumentFromInputSource(is);
} catch (NullPointerException e) {
logger.error("Problem with input xml: " + text);
throw new InvalidXmlSchemaException(e);
}
} }
/** /**
......
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