Package org.apache.jetspeed.profiler.rules

Examples of org.apache.jetspeed.profiler.rules.ProfilingRule


            {
                Iterator ruleEntries = rules.entrySet().iterator();
                while (ruleEntries.hasNext())
                {          
                    Map.Entry entry = (Map.Entry)ruleEntries.next();                   
                    ProfilingRule rule = profiler.getRule((String)entry.getValue());
                    if (rule != null)
                    {
                        Principal principal = SecurityHelper.getBestPrincipal(user.getSubject(), UserPrincipal.class);
                        profiler.setRuleForPrincipal(principal, rule, (String)entry.getKey());
                    }
View Full Code Here


                    {
                        try
                        {
                            String ruleName = getRuleName();
                            Profiler profiler = getServiceLocator().getProfiler();
                            ProfilingRule profilingRule = profiler.getRule(ruleName);
                            if (profilingRule != null)
                            {
                                profiler.setRuleForPrincipal(getPrincipal(), profilingRule, locatorName);
                            }
                            else
View Full Code Here

                this.fullRules = new ArrayList();
                this.userRules = new ArrayList();
                for (Iterator it = getServiceLocator().getProfiler().getRules()
                        .iterator(); it.hasNext();)
                {
                    ProfilingRule rule = (ProfilingRule) it.next();
                    this.fullRules.add(rule);
                }
                if (getPrincipal() != null)
                {
                    for (Iterator it = getServiceLocator().getProfiler()
View Full Code Here

                       
                        Profiler profiler = getServiceLocator().getProfiler();
                       
                        if (!StringUtils.isEmpty(getProfilingRule()))
                        {
                            ProfilingRule profilingRule = profiler.getRule(getProfilingRule());
                           
                            if (profilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, profilingRule, "default");
                            }
                            else
                            {
                                log.error("Failed to set profiling rule for principal. Invalid profiling rule: " + getProfilingRule());
                            }
                        }
                        else if (!StringUtils.isEmpty(defaultProfile))
                        {
                            ProfilingRule defaultProfilingRule = profiler.getRule(defaultProfile);
                           
                            if (defaultProfilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, defaultProfilingRule, "default");
                            }
View Full Code Here

            log.error(msg);
            throw new ProfilerException(msg);
        }

        // find a profiling rule for this principal
        ProfilingRule rule = getRuleForPrincipal(principal, locatorName);
        if (null == rule)
        {
            log.warn("Could not find profiling rule for principal: " + principal);
            rule = this.getDefaultRule();
        }

        if (null == rule)
        {
            String msg = "Couldn't find any profiling rules including default rule for principal " + principal;
            log.error(msg);
            throw new ProfilerException(msg);
        }
        // create a profile locator for given rule
        return rule.apply(context, this);
    }
View Full Code Here

    private ProfilingRule lookupProfilingRule( String ruleid )
    {
        // TODO: implement caching
        Filter filter = persistentStore.newFilter();
        Object query = persistentStore.newQuery(profilingRuleClass, filter);
        ProfilingRule rule = (ProfilingRule) persistentStore.getObjectByQuery(query);
        return rule;
    }
View Full Code Here

            log.error(msg);
            throw new ProfilerException(msg);
        }

        // find a profiling rule for this principal
        ProfilingRule rule = getRuleForPrincipal(principal, locatorName);
        if (null == rule)
        {
            log.warn("Could not find profiling rule for principal: " + principal);
            rule = this.getDefaultRule();
        }

        if (null == rule)
        {
            String msg = "Couldn't find any profiling rules including default rule for principal " + principal;
            log.error(msg);
            throw new ProfilerException(msg);
        }
        // create a profile locator for given rule
        return rule.apply(context, this);
    }
View Full Code Here

    }
   
    public ProfileLocator getDefaultProfile( RequestContext context, String locatorName ) throws ProfilerException
    {
      
        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);
    }
View Full Code Here

     * @see org.apache.jetspeed.profiler.Profiler#getRuleForPrincipal(java.security.Principal,
     *          java.lang.String)
     */
    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)
View Full Code Here

    {
        assertNotNull("profiler service is null", profiler);
        System.out.println("START: running test user role fallback...");
       
        // make sure rule is set correctly
        ProfilingRule rule = profiler.getRule("user-role-fallback");
        assertNotNull("rule is null ", rule);
        Iterator c = rule.getRuleCriteria().iterator();
        int ix = 0;
        while (c.hasNext())
        {
            RuleCriterion rc = (RuleCriterion)c.next();
            assertTrue("criterion type check " + rc.getType(), rc.getType().equals(URF_CRITERIA[ix]));
            System.out.println(rc.getType());
            ix++;
        }
       
        // test applying it
        RequestContext context = new MockRequestContext();
        Subject subject = createSubject();
        context.setPath("/homepage.psml");       
        context.setSubject(subject);
        ProfileLocator locator = rule.apply(context, profiler);
        System.out.println("locator = " + locator);
        assertTrue("locator string " + locator.toString(), locator.toString().equals("/homepage.psml:user:david:navigation:/:role:ATP:role:NB:role:ATP-NB:page:/homepage.psml"));
       
        System.out.println("COMPLETED: running test user role fallback.");
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.profiler.rules.ProfilingRule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.