Document document = DomUtil.makeDomFromSource(source, false);
XPath xPath = XPathFactory.newInstance().newXPath();
if ( ((Node) xPath.evaluate(
"/Capabilities", document, XPathConstants.NODE))==null) {
throw new HRInvalidResponseException(
"Received response has no 'Capabilities' node.");
}
Node recordsNode = (Node) xPath.evaluate(
"/Capabilities/OperationsMetadata/Operation[@name=\"GetRecords\"]",
document, XPathConstants.NODE);
Node recordByIdNode = (Node) xPath.evaluate(
"/Capabilities/OperationsMetadata/Operation[@name=\"GetRecordById\"]",
document, XPathConstants.NODE);
if (recordsNode==null || recordByIdNode==null) {
throw new HRInvalidResponseException(
"Received response has either no 'GetRecords' node," +
" or no 'GetRecordById' node.");
}
} catch (XPathExpressionException ex) {
throw new HRInvalidResponseException("Error parsing response.", ex);
} catch (SAXException ex) {
throw new HRInvalidResponseException("Error parsing response.", ex);
} catch (ParserConfigurationException ex) {
throw new HRInvalidResponseException("Error parsing response.", ex);
} catch (IOException ex) {
throw new HRInvalidResponseException("Error parsing response.", ex);
} finally {
try {
response.close();
} catch (IOException ignore) {
}