public ProfilingRule getRuleForPrincipal(Principal principal, String locatorName) { ProfilingRule rule = null; // lookup the rule for the given principal in our user/rule table PrincipalRule pr = lookupPrincipalRule(principal.getName(), locatorName); // if not found, fallback to the locator named rule or system wide rule if (pr == null) { // find rule on locator name rule = getRule(locatorName); if (rule == null) { // if not found, fallback to the system wide rule rule = getDefaultRule(); } pr = new PrincipalRuleImpl(); pr.setLocatorName(locatorName); pr.setPrincipalName(principal.getName()); pr.setProfilingRule(rule); principalRules.put(makePrincipalRuleKey(principal.getName(), locatorName), pr); // track cached principal rules trackCachedPrincipalRulesPut(principal.getName(), pr); } else { // Get the associated rule rule = pr.getProfilingRule(); } return rule; }