MatchResult match = policySet.match(context);
int result = match.getResult();
// if target matching was indeterminate, then return the error
if (result == MatchResult.INDETERMINATE)
return new PolicyFinderResult(match.getStatus());
// see if the target matched
if (result == MatchResult.MATCH) {
// see if we previously found another match
if (selectedPolicy != null) {
// we found a match before, so this is an error
ArrayList code = new ArrayList();
code.add(Status.STATUS_PROCESSING_ERROR);
Status status = new Status(code, "too many applicable "
+ "top-level policies");
return new PolicyFinderResult(status);
}
// this is the first match we've found, so remember it
selectedPolicy = policySet;
}
// return the single applicable policy (if there was one)
return new PolicyFinderResult(selectedPolicy);
}