monitor.problem(problem);
}
}
public Intent read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
Intent intent = null;
String intentLocalName = reader.getAttributeValue(null, NAME);
if (intentLocalName == null) {
error(context.getMonitor(), "IntentNameMissing", reader);
return null;
}
String intentType = reader.getAttributeValue(null, INTENT_TYPE);
if (intentType == null) {
intentType = Intent.Type.interaction.name();
}
intent = policyFactory.createIntent();
// [rfeng] the target namespace is not available, set the local part for now
// This will be changed in the definitions processor
intent.setName(new QName(intentLocalName));
intent.setType(Type.valueOf(intentType));
readRequiredIntents(intent, reader, context);
readExcludedIntents(intent, reader);
readConstrainedTypes(intent, reader);
String mutuallyExclusiveString = reader.getAttributeValue(null, MUTUALLY_EXCLUSIVE);
if (mutuallyExclusiveString != null &&
mutuallyExclusiveString.equals("true")){
intent.setMutuallyExclusive(true);
} else {
intent.setMutuallyExclusive(false);
}
Intent current = intent;
int event = reader.getEventType();
QName name = null;
while (reader.hasNext()) {
event = reader.getEventType();
switch (event) {
case START_ELEMENT: {
name = reader.getName();
if (DESCRIPTION_QNAME.equals(name)) {
String text = reader.getElementText();
if (text != null) {
text = text.trim();
}
current.setDescription(text);
} else if (INTENT_QUALIFIER_QNAME.equals(name)) {
String qualifierName = reader.getAttributeValue(null, NAME);
String defaultQ = reader.getAttributeValue(null, DEFAULT);
boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
Intent qualified = policyFactory.createIntent();
qualified.setUnresolved(false);
qualified.setType(intent.getType());
qualified.setName(new QName(qualifiedIntentName));
if (isDefault) {
if (intent.getDefaultQualifiedIntent() == null){
intent.setDefaultQualifiedIntent(qualified);
} else {
Monitor.error(context.getMonitor(),
this,
Messages.RESOURCE_BUNDLE,
"MultipleDefaultQualifiers",
intent.getName().toString());
}
}
// check that the qualifier is unique
if ( !intent.getQualifiedIntents().contains(qualified)){
intent.getQualifiedIntents().add(qualified);
} else {
Monitor.error(context.getMonitor(),
this,
Messages.RESOURCE_BUNDLE,
"QualifierIsNotUnique",
intent.getName().toString(),
qualifierName);
}
qualified.setQualifiableIntent(intent);
current = qualified;
}
break;
}
case END_ELEMENT: {