doc = DOMUtils.readXml(is);
} catch (Exception ex) {
throw new PolicyException(ex);
}
PolicyConstants constants = null;
if (null != bus) {
constants = bus.getExtension(PolicyConstants.class);
}
if (null == constants) {
constants = new PolicyConstants();
}
NodeList nl = doc.getElementsByTagNameNS(constants.getNamespace(),
constants.getPolicyAttachmentElemName());
for (int i = 0; i < nl.getLength(); i++) {
PolicyAttachment attachment = new PolicyAttachment();
Element ae = (Element)nl.item(i);
for (Node nd = ae.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
if (Node.ELEMENT_NODE != nd.getNodeType()) {
continue;
}
QName qn = new QName(nd.getNamespaceURI(), nd.getLocalName());
if (constants.getAppliesToElemQName().equals(qn)) {
Collection<DomainExpression> des = readDomainExpressions((Element)nd);
if (des.isEmpty()) {
// forget about this attachment
continue;
}
attachment.setDomainExpressions(des);
} else if (constants.getPolicyElemQName().equals(qn)) {
Policy p = builder.getPolicy((Element)nd);
if (null != attachment.getPolicy()) {
p = p.merge(attachment.getPolicy());
}
attachment.setPolicy(p);
} else if (constants.getPolicyReferenceElemQName().equals(qn)) {
PolicyReference ref = builder.getPolicyReference((Element)nd);
if (null != ref) {
Policy p = resolveReference(ref, doc);
if (null != attachment.getPolicy()) {
p = p.merge(attachment.getPolicy());