monitor.problem(problem);
}
}
public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
PolicySet policySet = null;
String policySetName = reader.getAttributeValue(null, NAME);
String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
if (policySetName == null || appliesTo == null) {
if (policySetName == null)
error("PolicySetNameMissing", reader);
if (appliesTo == null)
error("PolicySetAppliesToMissing", reader);
return policySet;
}
policySet = policyFactory.createPolicySet();
policySet.setName(new QName(policySetName));
String alwaysAppliesTo = reader.getAttributeValue(TUSCANY_NS, ALWAYS_APPLIES_TO);
//TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
//parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
//is doing is what the future version of the specs could be tending towards. When that happens
//this 'if' must be deleted
if (appliesTo != null && !appliesTo.startsWith("/")) {
appliesTo = "//" + appliesTo;
}
if (alwaysAppliesTo != null && !alwaysAppliesTo.startsWith("/")) {
alwaysAppliesTo = "//" + alwaysAppliesTo;
}
policySet.setAppliesTo(appliesTo);
policySet.setAlwaysAppliesTo(alwaysAppliesTo);
XPath path = xpathFactory.newXPath();
path.setNamespaceContext(reader.getNamespaceContext());
try {
if (appliesTo != null) {
policySet.setAppliesToXPathExpression(path.compile(appliesTo));
}
if (alwaysAppliesTo != null) {
policySet.setAlwaysAppliesToXPathExpression(path.compile(alwaysAppliesTo));
}
} catch (XPathExpressionException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", policySet, ce);
//throw ce;
}
readProvidedIntents(policySet, reader);
int event = reader.getEventType();
QName name = null;
reader.next();
while (reader.hasNext()) {
event = reader.getEventType();
switch (event) {
case START_ELEMENT: {
name = reader.getName();
if (POLICY_INTENT_MAP_QNAME.equals(name)) {
Intent mappedIntent = policyFactory.createIntent();
String provides = reader.getAttributeValue(null, PROVIDES);
if (provides != null) {
mappedIntent.setName(getQName(reader, PROVIDES));
if (policySet.getProvidedIntents().contains(mappedIntent)) {
readIntentMap(reader, policySet, mappedIntent);
} else {
error("IntentNotSpecified", policySet, policySetName);
//throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent PolicySet - " + policySetName);
}
} else {
error("IntentMapProvidesMissing", reader, policySetName);
}
} else if (POLICY_SET_REFERENCE_QNAME.equals(name)) {
PolicySet referredPolicySet = policyFactory.createPolicySet();
String referencename = reader.getAttributeValue(null, NAME);
if (referencename != null) {
referredPolicySet.setName(getQName(reader, NAME));
policySet.getReferencedPolicySets().add(referredPolicySet);
} else {
error("PolicySetReferenceNameMissing", reader, policySetName);
}
} /*else if ( WS_POLICY_QNAME.equals(name) ) {