Package org.apache.jetspeed.profiler.rules

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


                    return profilingRule.getRuleCriteria().size();
                }

                public IModel model(Object object)
                {
                    RuleCriterion ruleCriterion = (RuleCriterion) object;
                    return new Model(ruleCriterion);
                }

                public Iterator iterator(int first, int count)
                {
View Full Code Here


                else
                {
                    Iterator it = rule.getRuleCriteria().iterator();
                    while (it.hasNext())
                    {
                        RuleCriterion c = (RuleCriterion)it.next();
                        if (c.getName().equals(selected))
                        {
                            criterion = c;
                            isNew = false;
                            break;
                        }                   
View Full Code Here

        Collection col = p.getRuleCriteria();
        Iterator keys = col.iterator();
        while (keys.hasNext())
        {
            RuleCriterion rc = (RuleCriterion) keys.next();
            rule.getCriterions().add(new JSRuleCriterion(rc));
        }
        return rule;

    }
View Full Code Here

 
  {
    try
    {
 
        RuleCriterion c = profiler.createRuleCriterion();
        if (c == null)
          throw new SerializerException(
              SerializerException.CREATE_OBJECT_FAILED
                .create("org.apache.jetspeed.profiler.rules.RuleCriterion","returned null"));
        c.setFallbackOrder(jsr.getFallBackOrder());
        c.setFallbackType(jsr.getFallBackType());
        c.setName(jsr.getName());
        c.setType(jsr.getType());
        c.setValue(jsr.getValue());
        c.setRuleId(rule.getId());
        return c;
    }
    catch (Exception e)
    {
      SerializerException.CREATE_OBJECT_FAILED
View Full Code Here

       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
View Full Code Here

     public boolean equals(Object o)
    {
      if (this == o) return true;
      if ((o == null) || (!(o instanceof RuleCriterion)))
        return false;
      RuleCriterion r = (RuleCriterion)o;
      if (this.name != null)
      {
        if (!(this.name.equals(r.getName())))
            return false;
      }
      else
        if (r.getName() != null)
          return false;
      if (this.type != null)
      {
        if (!(this.type.equals(r.getType())))
            return false;
      }
      else
        if (r.getType() != null)
          return false;
      return true;     
     
    }
View Full Code Here

       
        // first pass, build the key
        Iterator criteria = this.getRuleCriteria().iterator();
        while (criteria.hasNext())
        {
            RuleCriterion criterion = (RuleCriterion)criteria.next();
            if (criterion.getType() == null)
            {
                log.warn("Invalid criterion provided - type null on rule " + this);
            }
            RuleCriterionResolver resolver = getResolver(criterion.getType());
            if (resolver == null)
            {
                resolver = getDefaultResolver();
            }
            String value = resolver.resolve(context, criterion);
            if (value != null && (resolver instanceof FallbackCriterionResolver))                   
            {
                StringTokenizer tokenizer = new StringTokenizer(value, StandardResolver.VALUE_DELIMITER);
                while (tokenizer.hasMoreTokens())
                {
                    String token = tokenizer.nextToken();
                    key.append(criterion.getName());
                    key.append(ProfileLocator.PATH_SEPARATOR);
                    key.append(token);
                    if (tokenizer.hasMoreTokens())
                    {
                        key.append(ProfileLocator.PATH_SEPARATOR);
                    }
                }
            }
            else
            {
                key.append(criterion.getName());
                key.append(ProfileLocator.PATH_SEPARATOR);
                key.append(value);
            }
            if (criteria.hasNext())
            {
                key.append(ProfileLocator.PATH_SEPARATOR);
            }
            count++;                                                                                                   
        }
        // try to get the profile locator from the cache,
        // request path and key sufficient to generate unique key
        String requestPath = context.getPath();
        String locatorKey = ((requestPath != null) ? requestPath : "/") + ProfileLocator.PATH_SEPARATOR + key.toString();
        ProfileLocator locator = getLocatorFromCache(locatorKey);
        if (locator != null)
        {
            return locator;
        }
       
        // second pass, build the locator object        
        locator = service.createLocator(context);
        criteria = this.getRuleCriteria().iterator();
        while (criteria.hasNext())
        {
            RuleCriterion criterion = (RuleCriterion)criteria.next();
            if (criterion.getType() == null)
            {
                log.warn("Invalid criterion provided - name or type null on rule " + this);
            }
            RuleCriterionResolver resolver = getResolver(criterion.getType());
            if (resolver != null)
            {
                String value = resolver.resolve(context, criterion);
                boolean isControl = resolver.isControl(criterion);
                boolean isNavigation = resolver.isNavigation(criterion);
View Full Code Here

        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();
View Full Code Here

        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();
View Full Code Here

        assertNotNull("Criteria is null", criteriaCollection);
        Iterator criteria = criteriaCollection.iterator();
        int count = 0;
        while (criteria.hasNext())
        {
            RuleCriterion criterion = (RuleCriterion) criteria.next();
            assertNotNull("criteria type ", criterion.getType());
            System.out.println("criteria name = " + criterion.getName());
            switch (count)
            {
            case 0:
                assertTrue("criteria name " + criterion.getName(), criterion.getName().equals(
                        ProfilingRule.STANDARD_PAGE));
                assertNotNull("criteria value", criterion.getValue());
                assertTrue("criteria value", criterion.getValue().equals(DEFAULT_PAGE));
                assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                break;
            case 1:
                assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_USER));
                assertNull("criteria value", criterion.getValue());
                assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                break;
            case 2:
                assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_MEDIATYPE));
                assertNull("criteria value", criterion.getValue());
                assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                break;
            case 3:
                assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_LANGUAGE));
                assertNull("criteria value", criterion.getValue());
                assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                break;
            case 4:
                assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_COUNTRY));
                assertNull("criteria value", criterion.getValue());
                assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                break;
            }
            count++;
        }
    }
View Full Code Here

TOP

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

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.