Package org.apache.jetspeed.profiler.rules

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


        Collection rules = getPersistenceBrokerTemplate().getCollectionByQuery(
                QueryFactory.newQuery(profilingRuleClass, new Criteria()));
        Iterator r = rules.iterator();
        while (r.hasNext())
        {
            ProfilingRule rule = (ProfilingRule) r.next();
            rule.setResolvers(resolvers);
        }
        return rules;
    }
View Full Code Here


    public ProfilingRule getRule(String id)
    {
        Criteria c = new Criteria();
        c.addEqualTo("id", id);

        ProfilingRule rule = (ProfilingRule) getPersistenceBrokerTemplate()
                .getObjectByQuery(QueryFactory.newQuery(profilingRuleClass, c));
        if (rule != null)
        {
            rule.setResolvers(resolvers);
        }
        return rule;
    }
View Full Code Here

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

        RequestContext request = new MockRequestContext("/football/nfl/chiefs");
        ProfilingRule rule = profiler.getRule("path");
        ProfileLocator locator = profiler.getProfile(request, rule);
        assertNotNull("rule test on getProfile returned null", locator);
        String path = locator.getLocatorPath();
        System.out.println("locator = " + path);
        assertTrue("locator path: " + path, path.equals("path:/football/nfl/chiefs"));
View Full Code Here

                QueryFactory.newQuery(getPrincipalRuleClass(), c));
        Iterator r = rules.iterator();
        while (r.hasNext())
        {
            PrincipalRule pr = (PrincipalRule) r.next();
            ProfilingRule rule = pr.getProfilingRule();
            if (rule != null) rule.setResolvers(resolvers);
        }
        this.rulesPerPrincipal.put(principal.getName(), rules);
        return rules;
    }
View Full Code Here

    public void testMaintenance() throws Exception
    {
        System.out.println("Maintenance tests commencing....");
        assertNotNull("profiler service is null", profiler);
        ProfilingRule rule = new StandardProfilingRule(resolvers);
        rule.setClassname("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
        rule.setId("testmo");
        rule.setTitle("The Grand Title");
        profiler.storeProfilingRule(rule);
        ProfilingRule rule2 = profiler.getRule("testmo");
        assertNotNull("rule couldnt be added", rule2);
        assertTrue("rule id bad", rule.getId().equals(rule2.getId()));

        rule2.setTitle("The New Title");
        profiler.storeProfilingRule(rule2);

        ProfilingRule rule3 = profiler.getRule("testmo");
        assertNotNull("rule couldnt be retrieved", rule3);
        assertTrue("rule title is bad", rule3.getTitle().equals(rule2.getTitle()));

        profiler.deleteProfilingRule(rule);
        ProfilingRule rule4 = profiler.getRule("testmo");
        assertNull("rule couldnt be deleted", rule4);

        System.out.println("Maintenance tests completed.");
    }
View Full Code Here

        String ruleId1 = "j1-test";
        String ruleId2 = "j2-test";
       
       
        // create org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule
        ProfilingRule rule = profiler.createProfilingRule(true);
        assertNotNull("rule is null ", rule);
        rule.setId(ruleId1);
        rule.setTitle("Test Rule 1");
        this.createStandardCriteria(rule);
       
        profiler.storeProfilingRule(rule);
        //Check
        ProfilingRule rule2 = profiler.getRule(ruleId1);
        assertNotNull("default rule couldnt be added", rule2);
        assertTrue("default rule id bad", rule.getId().equals(rule2.getId()));
       
        rule = profiler.createProfilingRule(false);
        assertNotNull("rule is null ", rule);
        rule.setId(ruleId2);
        rule.setTitle("Test Rule 2");
       
        this.createFallbackCriteria(rule);

        profiler.storeProfilingRule(rule);
        //Check
        rule2 = profiler.getRule(ruleId2);
        assertNotNull("fallback rule couldnt be added", rule2);
        assertTrue("fallback rule id bad", rule.getId().equals(rule2.getId()));

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

            {
                JSProfilingRule _c = (JSProfilingRule) _it.next();

                try
                {
                    ProfilingRule rule = null;

                    rule = pm.getRule(_c.getId());
                    if ((rule == null) || (isSettingSet(settings, JetspeedSerializer.KEY_OVERWRITE_EXISTING)))
                    {
                        rule = recreateRule(pm, rule, _c);
                        pm.storeProfilingRule(rule);
                    }
                }
                catch (Exception e)
                {
                    throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
                            "org.apache.jetspeed.capabilities.Capabilities", e.getLocalizedMessage()));
                }
            }
            /** reset the default profiling rule */
            String defaultRuleID = snapshot.getDefaultRule();
            if (defaultRuleID != null)
            {
                ProfilingRule defaultRule = pm.getRule(defaultRuleID);
                if (defaultRule != null)
                    pm.setDefaultRule(defaultRuleID);
            }
        }
        else
View Full Code Here

   
    private void recreatePrincipalRules(JSPrincipalRules rules, String principalName)
    {
        for (JSPrincipalRule pr : rules)
        {
            ProfilingRule pRule = pm.getRule(pr.getRule());

            try
            {
                PrincipalRule p1 = pm.createPrincipalRule();
                p1.setLocatorName(pr.getLocator());
View Full Code Here

     *             ClassNotFoundException, ProfilerException
     */
    protected ProfilingRule recreateRule(Profiler profiler, ProfilingRule existingRule, JSProfilingRule jsp)
            throws SerializerException, ClassNotFoundException, ProfilerException
    {
        ProfilingRule rule = null;
        boolean existing = false;

        if (existingRule == null)
        {
            rule = profiler.getRule(jsp.getId());
            if (jsp.isStandardRule())
                rule = profiler.createProfilingRule(true);
            else
                rule = profiler.createProfilingRule(false);
            rule.setId(jsp.getId());
        }
        else
        {
            rule = existingRule;
            existing = true;
        }

        rule.setTitle(jsp.getDescription());

        JSRuleCriterions col = jsp.getCriterions();

        Iterator _it = col.iterator();
        while (_it.hasNext())
        {
            RuleCriterion c = recreateRuleCriterion(profiler, (JSRuleCriterion) _it.next(), rule);
            if (c != null)
            {
                Collection cHelp = rule.getRuleCriteria();
                if (!(existing && (cHelp.contains(c))))
                {
                    cHelp.add(c);
                }
            }
View Full Code Here

    {
        HashMap rulesMap = new HashMap();
        Class standardRuleClass = null;
        try
        {
            ProfilingRule tempStandardRule = pm.createProfilingRule(true);
            standardRuleClass = tempStandardRule.getClass();
        }
        catch (Exception e)
        {
            throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(new String[] {
                    "Standard Rule", e.getMessage() }));
        }

        Iterator list = null;
        try
        {
            list = pm.getRules().iterator();
        }
        catch (Exception e)
        {
            throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] {
                    "ProfilingRules", e.getMessage() }));
        }
        while (list.hasNext())
        {
            try
            {
                ProfilingRule p = (ProfilingRule) list.next();
                if (!(rulesMap.containsKey(p.getId())))
                {
                    JSProfilingRule rule = createProfilingRule(p, (standardRuleClass == p.getClass()));
                    rulesMap.put(rule.getId(), rule);
                    snapshot.getRules().add(rule);

                }
            }
            catch (Exception e)
            {
                throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
                        "ProfilingRules", e.getMessage() }));
            }
        }

        // determine the defualt rule
        ProfilingRule defaultRule = pm.getDefaultRule();
        if (defaultRule != null)
            snapshot.setDefaultRule(defaultRule.getId());
    }
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.