Package org.apache.jetspeed.profiler.rules

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


            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

            {
                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)
                    {
                        profiler.setRuleForPrincipal(user, rule, (String)entry.getKey());
                    }
                }
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

    {
        assertNotNull("profiler service is null", profiler);
        System.out.println("START: running test user rolecombo fallback...");
       
        // make sure rule is set correctly
        ProfilingRule rule = profiler.getRule("user-rolecombo-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(URCF_CRITERIA[ix]));
            System.out.println(rc.getType());
            ix++;
        }
       
        // test applying it
        RequestContext context = new MockRequestContext();
        Subject subject = createSubject2();
        context.setPath("/homepage.psml");       
        context.setSubject(subject);
        ProfileLocator locator = rule.apply(context, profiler);
        System.out.println("locator = " + locator);                            //     /homepage.psml:user:david:navigation:/:role:ATP:role:NB:page:/homepage.psml
        assertTrue("locator string " + locator.toString(), locator.toString().equals("/homepage.psml:user:david:navigation:/:role:ATP-NB:page:/homepage.psml"));
       
        System.out.println("COMPLETED: running test user role fallback.");
    }
View Full Code Here

        // setup/maintain profiler context for session end notification
        setupProfilerContext(context);       

        // 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
    {
        // 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);
    }
View Full Code Here

    public void testRules() throws Exception
    {
        assertNotNull("profiler service is null", profiler);

        // Test Default Rule
        ProfilingRule rule = profiler.getDefaultRule();
        assertNotNull("Default profiling rule is null", rule);
        assertTrue("default rule unexpected, = " + rule.getId(), rule.getId().equals(DEFAULT_RULE));
        assertTrue("default rule class not mapped", rule instanceof StandardProfilingRule);

        // Test anonymous principal-rule
        ProfilingRule anonRule = profiler.getRuleForPrincipal(new UserImpl("anon"),
                ProfileLocator.PAGE_LOCATOR);
        assertNotNull("anonymous rule is null", anonRule);
        assertTrue("anonymous rule is j1", anonRule.getId().equals(DEFAULT_RULE));

        // Test Retrieving All Rules
        int standardCount = 0;
        int fallbackCount = 0;
        Iterator rules = profiler.getRules().iterator();
View Full Code Here

     *      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

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.