added guard clauses to VistaLinkSessionDao in case initUser RPC fails

This commit is contained in:
sblaz 2011-10-02 22:04:40 +00:00
parent 33169bafb6
commit 7969761ae0
1 changed files with 3 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import gov.va.med.edp.dao.SessionDao;
import gov.va.med.edp.vo.SessionVO;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.util.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
@ -54,6 +55,8 @@ public class VistaLinkSessionDao extends VistaLinkTrackingDao implements Session
}
private Document buildDocument(String result) {
if (!StringUtils.hasText(result)) throw new DataRetrievalFailureException("unable to get user info: EDPCTRL RPC(command=initUser) returned an empty response");
if (result.contains("error")) throw new DataRetrievalFailureException("unable to get user info: EDPCTRL RPC(command=initUser) returned an error");
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
return builder.parse(new InputSource(new StringReader("<results>" + result + "</results>")));