Map<String, AbstractPolicy> list =
new HashMap<String, AbstractPolicy>();
// get an iterator over all the identifiers
for (String policyId : policyList.keySet()) {
AbstractPolicy policy = policyList.get(policyId);
MatchResult match = policy.match(eval);
int result = match.getResult();
if (result == MatchResult.INDETERMINATE) {
throw new TopLevelPolicyException(match.getStatus());
}
// if we matched, we keep track of the matching policy...
if (result == MatchResult.MATCH) {
// ...first checking if this is the first match and if
// we automatically nest policies
if (m_combiningAlg == null && list.size() > 0) {
ArrayList<String> code = new ArrayList<String>();
code.add(Status.STATUS_PROCESSING_ERROR);
Status status =
new Status(code, "too many applicable"
+ " top-level policies");
throw new TopLevelPolicyException(status);
}
if (logger.isDebugEnabled()) {
logger.debug("Matched policy: {}", policyId);
}
list.put(policyId, policy);
}
}
// no errors happened during the search, so now take the right
// action based on how many policies we found
switch (list.size()) {
case 0:
return null;
case 1:
Iterator<AbstractPolicy> i = list.values().iterator();
AbstractPolicy p = i.next();
return p;
default:
return new PolicySet(parentPolicyId,
m_combiningAlg,
m_target,