private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver, ProcessorContext context)
throws ContributionResolveException {
Monitor monitor = context.getMonitor();
for (IntentMap intentMap : policySet.getIntentMaps()) {
Intent intent = intentMap.getProvidedIntent();
if (intent.isUnresolved()) {
Intent resolved = resolver.resolveModel(Intent.class, intent, context);
if (!resolved.isUnresolved() || resolved != intent) {
intentMap.setProvidedIntent(resolved);
} else {
error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
return;
//throw new ContributionResolveException("Mapped Intent - " + mappedIntent
//+ " not found for PolicySet " + policySet);
}
}
for (Qualifier qualifier : intentMap.getQualifiers()) {
intent = qualifier.getIntent();
if (intent.isUnresolved()) {
Intent resolved = resolver.resolveModel(Intent.class, intent, context);
if (!resolved.isUnresolved() || resolved != intent) {
qualifier.setIntent(resolved);
} else {
error(monitor, "MappedIntentNotFound", policySet, intent, policySet);
return;
//throw new ContributionResolveException("Mapped Intent - " + mappedIntent
//+ " not found for PolicySet " + policySet);
}
}
for (PolicyExpression exp : qualifier.getPolicies()) {
// FIXME: How to resolve the policies?
}
}
// validate that the intent map has a qualifier for each
// intent qualifier. The above code has already checked that the
// qualifiers that are there are resolved
Intent providedIntent = intentMap.getProvidedIntent();
if (intentMap.getQualifiers().size() != providedIntent.getQualifiedIntents().size()) {
String missingQualifiers = "";
for (Intent loopQualifiedIntent : providedIntent.getQualifiedIntents()) {
boolean found = false;
for (Qualifier loopQualifier : intentMap.getQualifiers()) {
if (loopQualifier.getIntent().getName().equals(loopQualifiedIntent.getName())) {
found = true;
break;
}
}
if (!found) {
missingQualifiers += loopQualifiedIntent.getName().getLocalPart() + " ";
}
}
if (missingQualifiers.length() > 0) {
Monitor.error(context.getMonitor(),
this,
Messages.RESOURCE_BUNDLE,
"IntentMapMissingQualifiers",
policySet.getName().toString(),
providedIntent.getName().getLocalPart(),
missingQualifiers);
}
}
}