subject.getRequiredIntents().add(i.getDefaultQualifiedIntent());
}
}
}
protected void resolveAndNormalize(PolicySubject subject, BuilderContext context) {
Definitions definitions = context.getDefinitions();
Set<Intent> intents = new HashSet<Intent>();
if (definitions != null) {
for (Intent i : subject.getRequiredIntents()) {
Intent resolved = resolve(definitions, i);
if (resolved != null) {
intents.add(resolved);
} else {
error(context.getMonitor(), "IntentNotFoundAtBuild", subject, i);
// Intent cannot be resolved
}
}
}
// Replace profile intents with their required intents
while (!intents.isEmpty()) {
boolean profileIntentsFound = false;
Set<Intent> copy = new HashSet<Intent>(intents);
for (Intent i : copy) {
if (!i.getRequiredIntents().isEmpty()) {
intents.remove(i);
intents.addAll(i.getRequiredIntents());
profileIntentsFound = true;
}
}
if (!profileIntentsFound) {
// No more profileIntents
break;
}
}
// Replace unqualified intents if there is a qualified intent in the list
Set<Intent> copy = new HashSet<Intent>(intents);
for (Intent i : copy) {
if (i.getQualifiableIntent() != null) {
intents.remove(i.getQualifiableIntent());
}
}
subject.getRequiredIntents().clear();
subject.getRequiredIntents().addAll(intents);
// TUSCANY-3503 - policy sets now only applied through direct
// or external attachement
// resolve policy set names that have been specified for the
// policy subject against the real policy sets from the
// definitions files
Set<PolicySet> policySets = new HashSet<PolicySet>();
if (definitions != null) {
for (PolicySet policySet : subject.getPolicySets()) {
int index = definitions.getPolicySets().indexOf(policySet);
if (index != -1) {
policySets.add(definitions.getPolicySets().get(index));
} else {
// PolicySet cannot be resolved
warning(context.getMonitor(), "PolicySetNotFoundAtBuild", subject, policySet);
}
}