Package org.apache.jetspeed.profiler.rules

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


                       
                        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


                    {
                        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

        // list of existing rules
        PageableListView rulesList = new PageableListView("rules", new PropertyModel(this, "rules"), 10) {

            @Override
            protected void populateItem(ListItem item) {
                final ProfilingRule rule = (ProfilingRule) item.getModelObject();
               
                item.add(new ActionPanel("ruleId", new Model(rule), new Link("link", new Model(rule)) {

                    @Override
                    public void onClick() {
                        ProfilingRule rule = (ProfilingRule) getModelObject();
                        setProfilingRule(rule);
                        ruleEditPanel.setVisible(true);
                        ruleEditPanel.hideCriterionEditPanel();
                        ruleEditPanel.ruleIdFieldReadOnly(true);
                    }
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

              {
                Iterator _itRoles = jsRules.iterator();
                  while (_itRoles.hasNext())
                  {
                    JSPrincipalRule pr = (JSPrincipalRule) _itRoles.next();
                    ProfilingRule pRule = pm.getRule(pr.getRule());
                   
                    try
                    {
                      PrincipalRule p1 = pm.createPrincipalRule();
                      p1.setLocatorName(pr.getLocator());
View Full Code Here

                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.profiler.Profiler"));
        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 (!(this.rulesMap.containsKey(p.getId())))
                {
                    JSProfilingRule rule = createProfilingRule(p, (standardRuleClass == p.getClass()));
                    rulesMap.put(rule.getId(), rule);
                    ((JSSeedData)getSnapshot()).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)
          ((JSSeedData)getSnapshot()).setDefaultRule(defaultRule.getId());

        // get Rules for each user

        Iterator _itUsers = this.userMap.values().iterator();
        while (_itUsers.hasNext())
View Full Code Here

     * @
     * @throws SerializerException, 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.remove(c); //remove existing duplicate
             cHelp.add(c); // add the current version back in
           }
       }
View Full Code Here

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

            try
            {
              ProfilingRule rule = null;
                
                 rule = pm.getRule(_c.getId());
                 if ((rule == null) || (this.getSetting(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 = ((JSSeedData)getSnapshot()).getDefaultRule();
          if (defaultRuleID != null)
          {
            ProfilingRule defaultRule = pm.getRule(defaultRuleID);
            if (defaultRule != null)
              pm.setDefaultRule(defaultRuleID);
          }
        }
        else
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.