public ProfileLocator getDefaultProfile(RequestContext context, String locatorName) throws ProfilerException { // find a profiling rule for the default principal ProfilingRule rule = getRuleForPrincipal(DEFAULT_RULE_PRINCIPAL, locatorName); if (null == rule) { log.warn("Could not find profiling rule for principal: " + DEFAULT_RULE_PRINCIPAL); rule = this.getDefaultRule(); } if (null == rule) { String msg = "Couldn't find any profiling rules including default rule for principal " + DEFAULT_RULE_PRINCIPAL; log.error(msg); throw new ProfilerException(msg); } // create a profile locator for given rule return rule.apply(context, this); }
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; }
log.warn("Could not find profiling rule for principal: " + principal); rule = this.getDefaultRule();