portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/webapp/WEB-INF/db/hsql Registry.script
Date Wed, 17 Dec 2003 20:46:34 GMT
taylor      2003/12/17 12:46:34

  Modified:    portal   maven.xml
               portal/src/java/org/apache/jetspeed/aggregator
                        Jetspeed1Aggregator.java
               portal/src/java/org/apache/jetspeed/capability/impl
                        CapabilityValveImpl.java
               portal/src/java/org/apache/jetspeed/profiler
                        ProfileLocator.java ProfilerService.java
               portal/src/java/org/apache/jetspeed/profiler/impl
                        JetspeedProfilerService.java
               portal/src/java/org/apache/jetspeed/profiler/rules
                        ProfilingRule.java RuleCriterion.java
                        RuleCriterionResolver.java
               portal/src/java/org/apache/jetspeed/profiler/rules/impl
                        AbstractProfilingRule.java
                        CountryCriterionResolver.java
                        RoleFallbackProfilingRule.java
                        RuleCriterionImpl.java StandardProfilingRule.java
                        StandardResolver.java
               portal/src/java/org/apache/jetspeed/request
                        JetspeedRequestContext.java RequestContext.java
               portal/src/sql/hsql populate-db-default.sql
               portal/src/test/org/apache/jetspeed/mockobjects/request
                        MockRequestContext.java
               portal/src/test/org/apache/jetspeed/profiler
                        TestProfiler.java
               portal/src/webapp/WEB-INF/conf/ojb repository_page.xml
               portal/src/webapp/WEB-INF/db/hsql Registry.script
  Added:       portal/src/java/org/apache/jetspeed/profiler/rules/impl
                        HardCodedResolver.java PathResolver.java
                        RequestSessionResolver.java
  Log:
  Profiler
  	- added more resolvers
  	- changed resolving to be based on type, not name of criterion
  	- added more testing rules
  
  Capability
  	- put text/html in request to fix bug when going to anywhere but index.jsp
  
  Revision  Changes    Path
  1.19      +1 -1      jakarta-jetspeed-2/portal/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/maven.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- maven.xml	8 Dec 2003 19:08:14 -0000	1.18
  +++ maven.xml	17 Dec 2003 20:46:33 -0000	1.19
  @@ -4,7 +4,7 @@
            xmlns:reactor="reactor">
   
     <!-- Target of maven test:single test -->
  -<property name='testcase' value='org.apache.jetspeed.spi.services.prefs.TestPreferences'/>        
  +<property name='testcase' value='org.apache.jetspeed.profiler.TestProfiler'/>        
    
   <!--
     <goal name="jaxb:portlet"
  
  
  
  1.2       +2 -2      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/Jetspeed1Aggregator.java
  
  Index: Jetspeed1Aggregator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/aggregator/Jetspeed1Aggregator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Jetspeed1Aggregator.java	4 Dec 2003 04:50:18 -0000	1.1
  +++ Jetspeed1Aggregator.java	17 Dec 2003 20:46:33 -0000	1.2
  @@ -151,7 +151,7 @@
        */
       public void build(RequestContext request) throws JetspeedException
       {
  -        Profile profile = (Profile)request.getRequestAttribute("j1-profile");
  +        Profile profile = (Profile)request.getAttribute("j1-profile");
           if (null == profile)
           {
               throw new JetspeedException("Failed to find Profile in BasicAggregator.build");
  
  
  
  1.2       +2 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/capability/impl/CapabilityValveImpl.java
  
  Index: CapabilityValveImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/capability/impl/CapabilityValveImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CapabilityValveImpl.java	5 Dec 2003 21:09:21 -0000	1.1
  +++ CapabilityValveImpl.java	17 Dec 2003 20:46:33 -0000	1.2
  @@ -131,6 +131,7 @@
               
               // Put the Mime Type into the request
               request.setMimeType("text/html");
  +            request.getResponse().setContentType("text/html");
   
           } 
           catch (Exception e)
  
  
  
  1.4       +8 -6      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfileLocator.java
  
  Index: ProfileLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfileLocator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProfileLocator.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ ProfileLocator.java	17 Dec 2003 20:46:33 -0000	1.4
  @@ -68,14 +68,16 @@
    * The format of the path is name/value pairs of all property, separated by a <i>path separator</i>.
    * An example locator path:</p>
    * 
  - *      <pre>/desktop/default-desktop.psml/page/default.psml/artist/al-stewart/song/on-the-border</pre>
  + *      <pre>desktop:default-desktop.psml:page:default.psml:artist:al-stewart:song:on-the-border</pre>
  + *      <pre>desktop:default-desktop.psml:path:/sports/football/nfl/chiefs:language:en</pre>
  + * 
    *
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
   public interface ProfileLocator 
   {
  -    public final static String PATH_SEPARATOR = "/";
  +    public final static String PATH_SEPARATOR = ":";
           
       /**
        * Get an iterator over the locator's properties.
  @@ -113,10 +115,10 @@
       
       /**
        * <p>Profiles can be created from a normalized <i>Profile Locator Path</i>
  -     * The format of the path is name/value pairs of all property, separated by a <i>path separator</i>.
  +     * The format of the path is name:value pairs of all property, separated by a <i>path separator</i>.
        * An example locator path:</p>
        * 
  -     *      <pre>/desktop/default-desktop.psml/page/default.psml/artist/air/song/all-i-need</pre>
  +     *      <pre>:desktop:default-desktop.psml:page:default.psml:artist:air:song:all-i-need</pre>
        * 
        * @param path The normalized path as shown above from which the locator is created.
        */
  @@ -127,7 +129,7 @@
        * The format of the path is name/value pairs of all property, separated by a <i>path separator</i>.
        * An example locator path:</p>
        * 
  -     *      <pre>/desktop/default-desktop.psml/page/default.psml/artist/joni-mitchell/song/cary</pre>
  +     *      <pre>:desktop:default-desktop.psml:page:default.psml:artist:joni-mitchell:song:cary</pre>
        * 
        * @return The normalized path as shown above.
        */
  
  
  
  1.4       +19 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfilerService.java
  
  Index: ProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfilerService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProfilerService.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ ProfilerService.java	17 Dec 2003 20:46:33 -0000	1.4
  @@ -100,6 +100,15 @@
        */
       ProfileLocator getProfile(RequestContext context)
           throws ProfilerException;
  +
  +    /**
  +     *  Get the Profile object using the request parameters and the rule.
  +     *
  +     * @param context The request context
  +     * @return a new Profile Locator object or null if failed to find a appropriate locator.
  +     */        
  +    ProfileLocator getProfile(RequestContext context, ProfilingRule rule)
  +        throws ProfilerException;        
       
       /**
        * @param locator
  @@ -147,6 +156,14 @@
        */
       Collection getRules();
   
  +    /**
  +     * Given a rule id, get the rule
  +     * 
  +     * @param id
  +     * @return the rule
  +     */
  +    ProfilingRule getRule(String id);
  +    
       /**
        * @return
        */
  
  
  
  1.4       +22 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfilerService.java
  
  Index: JetspeedProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfilerService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedProfilerService.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ JetspeedProfilerService.java	17 Dec 2003 20:46:33 -0000	1.4
  @@ -167,7 +167,16 @@
           // create a profile locator for given rule
           return rule.apply(context, this);
       }
  -        
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.profiler.ProfilerService#getProfile(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.rules.ProfilingRule)
  +     */
  +    public ProfileLocator getProfile(RequestContext context, ProfilingRule rule)
  +    {        
  +        // create a profile locator for given rule
  +        return rule.apply(context, this);                
  +    }
  +    
       /* (non-Javadoc)
        * @see org.apache.jetspeed.profiler.ProfilerService#getDefaultRule()
        */
  @@ -299,6 +308,17 @@
       public Collection getRules()
       {
           return plugin.getExtent(profilingRuleClass);
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.profiler.ProfilerService#getRule(java.lang.String)
  +     */
  +    public ProfilingRule getRule(String id)
  +    {
  +        LookupCriteria criteria = plugin.newLookupCriteria();
  +        criteria.addEqualTo("id", id);
  +        Object query = plugin.generateQuery(profilingRuleClass, criteria);
  +        return (ProfilingRule) plugin.getObjectByQuery(profilingRuleClass, query);        
       }
   
       /* (non-Javadoc)
  
  
  
  1.4       +3 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
  
  Index: ProfilingRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProfilingRule.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ ProfilingRule.java	17 Dec 2003 20:46:33 -0000	1.4
  @@ -54,7 +54,6 @@
   package org.apache.jetspeed.profiler.rules;
   
   import java.util.Collection;
  -
   import org.apache.jetspeed.profiler.ProfileLocator;
   import org.apache.jetspeed.profiler.ProfilerService;
   import org.apache.jetspeed.request.RequestContext;
  @@ -89,8 +88,8 @@
       public final static String REQUEST_PARAMETER = "request";
       /** Request attributes as defined in the Portlet spec 1.0 PLT.11.1.3 */
       public final static String REQUEST_ATTRIBUTE = "attribute";
  -    /** Request parameters as defined in the Portlet spec 1.0 PLT.11.1.4 */    
  -    public final static String REQUEST_PROPERTY = "property";
  +    /** Session Attribute */    
  +    public final static String SESSION_ATTRIBUTE = "session";
       /** User attributes as defined in the Portlet spec 1.0 PLT.17 */
       public final static String USER_ATTRIBUTE = "user";
       /** Composite Capabilities and Preference Profile as defined http://www.w3.org/TR/NOTE-CCPP/ */
  
  
  
  1.4       +2 -3      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java
  
  Index: RuleCriterion.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RuleCriterion.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ RuleCriterion.java	17 Dec 2003 20:46:33 -0000	1.4
  @@ -152,8 +152,7 @@
        */        
       void setName(String name);
   
  -    String getResolverName();
  -    
  +   
       /**
        * Gets the value of the parameter, attribute or property in the portal request.
        *  
  
  
  
  1.2       +41 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterionResolver.java
  
  Index: RuleCriterionResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterionResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RuleCriterionResolver.java	4 Dec 2003 04:50:18 -0000	1.1
  +++ RuleCriterionResolver.java	17 Dec 2003 20:46:33 -0000	1.2
  @@ -57,13 +57,52 @@
   
   /**
    * Resolves rule criterion based on a single criterion and 
  - * runtime request context state. 
  + * runtime request context state. Note all resolvers should
  + * look at the criterion's value if they fail to find it
    * 
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
   public interface RuleCriterionResolver
   {
  +    /** resolve the parameter via the request parameter, then value */        
  +    public static final String REQUEST = "request";
  +    
  +    /** resolve the parameter via a session attribute */
  +    public static final String SESSION = "session";
  +    
  +    /** look in the request first, then session */
  +    public static final String REQUEST_SESSION = "request.session";
  +    
  +    /** look at hard-coded criterion value only */
  +    public final static String  HARD_CODED = "hard.coded";
  +    
  +    /** look for group, then role, then user */
  +    public final static String GROUP_ROLE_USER = "group.role.user";
  +
  +    /** first check request parameter, then check user in the request context */             
  +    public final static String USER = "user";
  +    
  +    /** first check request parameter, then check group in the request context */             
  +    public final static String GROUP = "group";
  +    
  +    /** first check request parameter, then check role in the request context */             
  +    public final static String ROLE = "role";
  +    
  +    /** first check request parameter, then check media type in the request context */             
  +    public final static String MEDIATYPE = "mediatype";
  +    
  +    /** first check request parameter, then check country code in the request context */                 
  +    public final static String COUNTRY = "country";
  +    
  +    /** first check request parameter, then check language in the request context */                 
  +    public final static String LANGUAGE = "language";
  +    
  +    public final static String ROLE_FALLBACK = "roles";
  +
  +    /** resolve the parameter via the request path, then value */        
  +    public static final String PATH = "path";
  +    
       /**
        * Resolver the value for a criterion.
        * 
  
  
  
  1.4       +13 -15    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
  
  Index: AbstractProfilingRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractProfilingRule.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ AbstractProfilingRule.java	17 Dec 2003 20:46:34 -0000	1.4
  @@ -76,8 +76,6 @@
       protected String id;
       protected String title;
       protected String ojbConcreteClass;
  -
  -    protected static final String DEFAULT_RESOLVER = "AbstractProfilingRule.default";
       
       /** Map of profile locators kept around for reuse TODO: evict entries after max size reached */    
       static Map locators = new HashMap();
  @@ -87,17 +85,17 @@
       
       static 
       {
  -        RuleCriterionResolver standardResolver = new StandardResolver();
  -        resolvers.put(DEFAULT_RESOLVER, standardResolver);
  -        resolvers.put(ProfilingRule.STANDARD_DESKTOP, standardResolver);        
  -        resolvers.put(ProfilingRule.STANDARD_PAGE, standardResolver);
  -        resolvers.put(ProfilingRule.STANDARD_USER, new UserCriterionResolver());
  -        resolvers.put(ProfilingRule.STANDARD_ROLE, new RoleCriterionResolver()); 
  -        resolvers.put(ProfilingRule.STANDARD_GROUP, new GroupCriterionResolver());          
  -        resolvers.put(ProfilingRule.STANDARD_MEDIATYPE, new MediatypeCriterionResolver());
  -        resolvers.put(ProfilingRule.STANDARD_LANGUAGE, new LanguageCriterionResolver());
  -        resolvers.put(ProfilingRule.STANDARD_COUNTRY, new CountryCriterionResolver());
  -        resolvers.put(ProfilingRule.STANDARD_GROUP_ROLE_USER, new GroupRoleUserCriterionResolver());                         
  +        resolvers.put(RuleCriterionResolver.REQUEST, new StandardResolver());
  +        resolvers.put(RuleCriterionResolver.REQUEST_SESSION, new RequestSessionResolver());
  +        resolvers.put(RuleCriterionResolver.PATH, new PathResolver());        
  +        resolvers.put(RuleCriterionResolver.HARD_CODED, new HardCodedResolver());
  +        resolvers.put(RuleCriterionResolver.USER, new UserCriterionResolver());
  +        resolvers.put(RuleCriterionResolver.ROLE, new RoleCriterionResolver()); 
  +        resolvers.put(RuleCriterionResolver.GROUP, new GroupCriterionResolver());          
  +        resolvers.put(RuleCriterionResolver.MEDIATYPE, new MediatypeCriterionResolver());
  +        resolvers.put(RuleCriterionResolver.LANGUAGE, new LanguageCriterionResolver());
  +        resolvers.put(RuleCriterionResolver.COUNTRY, new CountryCriterionResolver());
  +        resolvers.put(RuleCriterionResolver.GROUP_ROLE_USER, new GroupRoleUserCriterionResolver());                         
       }
       
       protected ProfileLocator getLocatorFromCache(String key)
  @@ -121,7 +119,7 @@
   
       public RuleCriterionResolver getDefaultResolver()
       {
  -        return (RuleCriterionResolver)resolvers.get(DEFAULT_RESOLVER);
  +        return (RuleCriterionResolver)resolvers.get(RuleCriterionResolver.REQUEST);
       }
       
       /* (non-Javadoc)
  
  
  
  1.2       +4 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/CountryCriterionResolver.java
  
  Index: CountryCriterionResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/CountryCriterionResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CountryCriterionResolver.java	4 Dec 2003 04:50:18 -0000	1.1
  +++ CountryCriterionResolver.java	17 Dec 2003 20:46:34 -0000	1.2
  @@ -59,6 +59,9 @@
   
   /**
    * CountryCriterionResolver
  + * Resolve Rules:
  + *     1. Request Parameter (Standard)
  + *     2. Locale.CountryCode 
    *
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
  
  
  
  1.3       +65 -4     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java
  
  Index: RoleFallbackProfilingRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RoleFallbackProfilingRule.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RoleFallbackProfilingRule.java	4 Dec 2003 04:50:18 -0000	1.2
  +++ RoleFallbackProfilingRule.java	17 Dec 2003 20:46:34 -0000	1.3
  @@ -53,9 +53,15 @@
    */
   package org.apache.jetspeed.profiler.rules.impl;
   
  +import java.util.Iterator;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.profiler.ProfileLocator;
   import org.apache.jetspeed.profiler.ProfilerService;
   import org.apache.jetspeed.profiler.rules.ProfilingRule;
  +import org.apache.jetspeed.profiler.rules.RuleCriterion;
  +import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
   import org.apache.jetspeed.request.RequestContext;
   
   /**
  @@ -68,13 +74,68 @@
       extends AbstractProfilingRule
       implements ProfilingRule
   {
  +    protected final static Log log = LogFactory.getLog(RoleFallbackProfilingRule.class);
  +    
       /* (non-Javadoc)
        * @see org.apache.jetspeed.profiler.rules.ProfilingRule#apply(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.ProfilerService)
        */
       public ProfileLocator apply(RequestContext context, ProfilerService service)
       {
  -        // TODO Auto-generated method stub  - implement this      
  -        ProfileLocator locator = service.createLocator();
  -        return locator; // need to implement this one still
  +        StringBuffer key = new StringBuffer();
  +        int count = 0;
  +        
  +        // 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);
  +            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        
  +        String locatorKey = key.toString();
  +        ProfileLocator locator = getLocatorFromCache(locatorKey); 
  +        if (locator != null)
  +        {
  +            return locator;
  +        }
  +        
  +        // second pass, build the locator object         
  +        locator = service.createLocator();
  +        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);
  +                locator.add(criterion, value);
  +            }                
  +        }               
  +             
  +        addLocatorToCache(locatorKey, locator);
  +        return locator; 
  +        
       }
   }
  
  
  
  1.4       +2 -23     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RuleCriterionImpl.java
  
  Index: RuleCriterionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RuleCriterionImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RuleCriterionImpl.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ RuleCriterionImpl.java	17 Dec 2003 20:46:34 -0000	1.4
  @@ -67,7 +67,6 @@
       private String ruleId;
       private String type;
       private String name = null;
  -    private String resolverName;    
       private String value;
       private int fallbackType = RuleCriterion.FALLBACK_CONTINUE;
       private int fallbackOrder;
  @@ -78,7 +77,6 @@
   
       public RuleCriterionImpl(RuleCriterion master)
       {
  -        this.resolverName = master.getResolverName();        
           this.name = master.getName();
           this.ruleId = master.getRuleId();
           this.type = master.getType();
  @@ -108,10 +106,6 @@
        */
       public String getName()
       {
  -        if (this.name == null)
  -        {
  -            return this.resolverName;
  -        }
           return this.name;
       }
       
  @@ -187,20 +181,5 @@
           fallbackType = i;
       }
   
  -    /**
  -     * @return
  -     */
  -    public String getResolverName()
  -    {
  -        return resolverName;
  -    }
  -
  -    /**
  -     * @param string
  -     */
  -    public void setResolverName(String string)
  -    {
  -        resolverName = string;
  -    }
  -
  +    
   }
  
  
  
  1.4       +20 -30    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardProfilingRule.java
  
  Index: StandardProfilingRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardProfilingRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardProfilingRule.java	4 Dec 2003 04:50:18 -0000	1.3
  +++ StandardProfilingRule.java	17 Dec 2003 20:46:34 -0000	1.4
  @@ -91,31 +91,24 @@
           while (criteria.hasNext())
           {
               RuleCriterion criterion = (RuleCriterion)criteria.next();
  -            if (criterion.getResolverName() == null || criterion.getType() == null)
  +            if (criterion.getType() == null)
               {
  -                log.warn("Invalid criterion provided - name or type null on rule " + this);
  +                log.warn("Invalid criterion provided - type null on rule " + this);
               }
  -            if (criterion.getType().equals(ProfilingRule.STANDARD))
  +            RuleCriterionResolver resolver = getResolver(criterion.getType());
  +            if (resolver == null)
               {
  -                RuleCriterionResolver resolver = getResolver(criterion.getResolverName());
  -                if (resolver == null)
  -                {
  -                    resolver = getDefaultResolver();
  -                }
  -                String value = resolver.resolve(context, criterion);
  -                key.append(criterion.getName());
  -                key.append(ProfileLocator.PATH_SEPARATOR);
  -                key.append(value);
  -                if (criteria.hasNext())
  -                {
  -                    key.append(ProfileLocator.PATH_SEPARATOR);
  -                }
  -                count++;                                                                                                    
  +                resolver = getDefaultResolver();
               }
  -            else
  +            String value = resolver.resolve(context, criterion);
  +            key.append(criterion.getName());
  +            key.append(ProfileLocator.PATH_SEPARATOR);
  +            key.append(value);
  +            if (criteria.hasNext())
               {
  -                // ignore: only handles standard criteria
  +                key.append(ProfileLocator.PATH_SEPARATOR);
               }
  +            count++;                                                                                                    
           }
           
           // try to get the profile locator from the cache        
  @@ -132,19 +125,16 @@
           while (criteria.hasNext())
           {
               RuleCriterion criterion = (RuleCriterion)criteria.next();
  -            if (criterion.getResolverName() == null || criterion.getType() == null)
  +            if (criterion.getType() == null)
               {
  -                log.warn("Invalid criterion provided - name or type null on rule " + this);
  +                log.warn("Invalid criterion provided - type null on rule " + this);
               }
  -            if (criterion.getType().equals(ProfilingRule.STANDARD))
  +            RuleCriterionResolver resolver = getResolver(criterion.getType());
  +            if (resolver != null)
               {
  -                RuleCriterionResolver resolver = getResolver(criterion.getResolverName());
  -                if (resolver != null)
  -                {
  -                    String value = resolver.resolve(context, criterion);
  -                    locator.add(criterion, value);
  -                }                
  -            }
  +                String value = resolver.resolve(context, criterion);
  +                locator.add(criterion, value);
  +            }                
           }               
                
           addLocatorToCache(locatorKey, locator);
  
  
  
  1.2       +3 -3      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java
  
  Index: StandardResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StandardResolver.java	4 Dec 2003 04:50:18 -0000	1.1
  +++ StandardResolver.java	17 Dec 2003 20:46:34 -0000	1.2
  @@ -59,8 +59,8 @@
   
   /**
    * Standard Jetspeed-1 style resolver for criterion.
  - * It first looks at the value in the criterion record.
  - * If it is null, it then falls back to a request parameter.
  + * It first looks at the value in the request parameters.
  + * If it is null, it then falls back to the criterion record..
    * If it is null it gives up and returns null allowing subclasses
    * to continue processing.
    *
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/HardCodedResolver.java
  
  Index: HardCodedResolver.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.profiler.rules.impl;
  
  import org.apache.jetspeed.profiler.rules.RuleCriterion;
  import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
  import org.apache.jetspeed.request.RequestContext;
  
  /**
   * HardCodedResolver
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: HardCodedResolver.java,v 1.1 2003/12/17 20:46:34 taylor Exp $
   */
  public class HardCodedResolver implements RuleCriterionResolver
  {
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.rules.RuleCriterion)
       */
      public String resolve(RequestContext context, RuleCriterion criterion)
      {
          return criterion.getValue();
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/PathResolver.java
  
  Index: PathResolver.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.profiler.rules.impl;
  
  import org.apache.jetspeed.profiler.rules.RuleCriterion;
  import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
  import org.apache.jetspeed.request.RequestContext;
  
  /**
   * PathResolver
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: PathResolver.java,v 1.1 2003/12/17 20:46:34 taylor Exp $
   */
  public class PathResolver implements RuleCriterionResolver
  {
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.rules.RuleCriterion)
       */
      public String resolve(RequestContext context, RuleCriterion criterion)
      {
          String path = context.getPath();
          if (path == null)
          {
              path = criterion.getValue();
          }
          return path;
      }
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RequestSessionResolver.java
  
  Index: RequestSessionResolver.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.profiler.rules.impl;
  
  import org.apache.jetspeed.profiler.rules.RuleCriterion;
  import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
  import org.apache.jetspeed.request.RequestContext;
  
  /**
   * RequestSessionResolver
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: RequestSessionResolver.java,v 1.1 2003/12/17 20:46:34 taylor Exp $
   */
  public class RequestSessionResolver implements RuleCriterionResolver
  {
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.rules.RuleCriterionResolver#resolve(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.rules.RuleCriterion)
       */
      public String resolve(RequestContext context, RuleCriterion criterion)
      {
          String value = context.getRequestParameter(criterion.getName());
          if (value == null)
          {
              // TODO: this attribute needs to be prefixed to avoid collisions with other *portal* attributes
              value = (String)context.getSessionAttribute(criterion.getName());
              if (value == null)
              {
                  value = criterion.getValue();
              }
          }
          return value;            
      }
  }
  
  
  
  1.7       +41 -1     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java
  
  Index: JetspeedRequestContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JetspeedRequestContext.java	4 Dec 2003 04:50:19 -0000	1.6
  +++ JetspeedRequestContext.java	17 Dec 2003 20:46:34 -0000	1.7
  @@ -372,6 +372,46 @@
           return request.getAttribute(key);        
       }
       
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getSessionAttribute(java.lang.String)
  +     */
  +    public Object getSessionAttribute(String key)
  +    {
  +        return request.getSession().getAttribute(key);
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#setSessionAttribute(java.lang.String, java.lang.Object)
  +     */
  +    public void setSessionAttribute(String key, Object value)
  +    {
  +        request.getSession().setAttribute(key, value);    
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#setAttribute(java.lang.String, java.lang.Object)
  +     */
  +    public void setAttribute(String key, Object value)
  +    {
  +        request.setAttribute(key, value);
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getAttribute(java.lang.String)
  +     */
  +    public Object getAttribute(String key)
  +    {
  +        return request.getAttribute(key);    
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getPath()
  +     */
  +    public String getPath()
  +    {
  +        return request.getPathInfo();
  +    }
   }
   
   
  
  
  
  1.6       +52 -2     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/RequestContext.java
  
  Index: RequestContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/RequestContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RequestContext.java	4 Dec 2003 04:50:19 -0000	1.5
  +++ RequestContext.java	17 Dec 2003 20:46:34 -0000	1.6
  @@ -292,5 +292,55 @@
        */
       Map getParameterMap();
   
  -    Object getRequestAttribute(String key);        
  +    
  +    /**
  +     * Gets an attribute from the session.
  +     * This method is decoupled from the servlet api request to 
  +     * facilitate abstractions for testing and other programs not 
  +     * connected to a servlet application.
  +     * 
  +     * @param key The key of the attribute
  +     * @return The value of the attribute
  +     */
  +    Object getSessionAttribute(String key);
  +
  +    /**
  +     * Sets an attribute into the session.
  +     * This method is decoupled from the servlet api request to 
  +     * facilitate abstractions for testing and other programs not 
  +     * connected to a servlet application.
  +     * 
  +     * @param key The key of the session attribute
  +     * @param value The value of the session attribute
  +     */    
  +    void setSessionAttribute(String key, Object value);
  +    
  +    /**
  +     * Get a request attribute associated with this single request.
  +     * 
  +     * @param key The key of the request attribute
  +     * @return The value of the request attribute
  +     */
  +    Object getAttribute(String key);
  +                
  +    /**
  +     * Sets an attribute into the request.
  +     * This method is decoupled from the servlet api request to 
  +     * facilitate abstractions for testing and other programs not 
  +     * connected to a servlet application.
  +     * 
  +     * @param key The key of the request attribute
  +     * @param value The value of the request attribute
  +     */    
  +    void setAttribute(String key, Object value);
  +      
  +    /**
  +     * Returns any extra path information associated with the URL the 
  +     * client sent when it made this request. The extra path information 
  +     * follows the servlet path but precedes the query string. 
  +     * This method returns null if there was no extra path information.
  +     * 
  +     * @return the path 
  +     */
  +    String getPath();                    
   }
  
  
  
  1.6       +14 -12    jakarta-jetspeed-2/portal/src/sql/hsql/populate-db-default.sql
  
  Index: populate-db-default.sql
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/sql/hsql/populate-db-default.sql,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- populate-db-default.sql	6 Dec 2003 02:06:11 -0000	1.5
  +++ populate-db-default.sql	17 Dec 2003 20:46:34 -0000	1.6
  @@ -241,22 +241,24 @@
   insert into PROFILING_RULE values ('j1', 
      'org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule',
      'The default profiling rule following the Jetspeed-1 hard-coded profiler fallback algorithm.');
  -insert into RULE_CRITERION values (1, 'j1', 0, 'standard', 'desktop', 'default-desktop', 0);
  -insert into RULE_CRITERION values (2, 'j1', 1, 'standard', 'page', 'default-page', 0);
  -insert into RULE_CRITERION values (3, 'j1', 2, 'standard', 'group.role.user', null, 0);
  -insert into RULE_CRITERION values (4, 'j1', 3, 'standard', 'mediatype', null, 1);
  -insert into RULE_CRITERION values (5, 'j1', 4, 'standard', 'language', null, 1);
  -insert into RULE_CRITERION values (6, 'j1', 5, 'standard', 'country', null, 1);
  +insert into RULE_CRITERION values (1, 'j1', 0, 'request.session', 'desktop', 'default-desktop', 0);
  +insert into RULE_CRITERION values (2, 'j1', 1, 'request.session', 'page', 'default-page', 0);
  +insert into RULE_CRITERION values (3, 'j1', 2, 'group.role.user', 'user', null, 0);
  +insert into RULE_CRITERION values (4, 'j1', 3, 'mediatype', 'mediatype', null, 1);
  +insert into RULE_CRITERION values (5, 'j1', 4, 'language', 'language', null, 1);
  +insert into RULE_CRITERION values (6, 'j1', 5, 'country', 'country', null, 1);
   
   insert into PROFILING_RULE values ('role-fallback', 
        'org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule',
        'A role based fallback algorithm based on Jetspeed-1 role-based fallback');
  -insert into RULE_CRITERION values (7, 'role-fallback', 0, 'standard', 'desktop', 'default-desktop', 0);
  -insert into RULE_CRITERION values (8, 'role-fallback', 1, 'standard', 'page', 'default-page', 0);
  -insert into RULE_CRITERION values (9, 'role-fallback', 2, 'standard', 'roles', null, 2);
  -insert into RULE_CRITERION values (10, 'role-fallback', 3, 'standard', 'mediatype', null, 1);
  -insert into RULE_CRITERION values (11, 'role-fallback', 4, 'standard', 'language', null, 1);
  -insert into RULE_CRITERION values (12, 'role-fallback', 5, 'standard', 'country', null, 1);
  +insert into RULE_CRITERION values (7, 'role-fallback', 0, 'request.session', 'desktop', 'default-desktop', 0);
  +insert into RULE_CRITERION values (8, 'role-fallback', 1, 'request.session', 'page', 'default-page', 0);
  +insert into RULE_CRITERION values (9, 'role-fallback', 2, 'role', 'role', null, 2);
  +
  +insert into PROFILING_RULE values ('path', 
  +   'org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule',
  +   'use a path to locate.');
  +insert into RULE_CRITERION values (10, 'path', 0, 'path', 'path', '/', 0);
   
   insert into PRINCIPAL_RULE_ASSOC values ( 'anon', 'j1' );
   
  
  
  
  1.2       +48 -4     jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/mockobjects/request/MockRequestContext.java
  
  Index: MockRequestContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/mockobjects/request/MockRequestContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MockRequestContext.java	4 Dec 2003 18:38:11 -0000	1.1
  +++ MockRequestContext.java	17 Dec 2003 20:46:34 -0000	1.2
  @@ -70,11 +70,19 @@
   {
       private Map requestParameters = new HashMap();
       private Map requestAttributes = new HashMap();
  +    private Map sessionAttributes = new HashMap();
  +    private String path;
           
       public MockRequestContext(PortalContext pc)
       {
           super(pc, null, null, null);
       }
  +
  +    public MockRequestContext(PortalContext pc, String path)
  +    {
  +        super(pc, null, null, null);
  +        this.path = path;
  +    }
           
       /* (non-Javadoc)
        * @see org.apache.jetspeed.request.RequestContext#getRequestParameter(java.lang.String)
  @@ -91,9 +99,45 @@
       {
           return requestParameters;    
       }
  -        
  -    public Object getRequestProperty(String key)
  +            
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#setSessionAttribute(java.lang.String, java.lang.Object)
  +     */
  +    public void setSessionAttribute(String key, Object value)
  +    {
  +        this.sessionAttributes.put(key, value);
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getSessionAttribute(java.lang.String)
  +     */
  +    public Object getSessionAttribute(String key)
  +    {
  +        return this.sessionAttributes.get(key);
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#setAttribute(java.lang.String, java.lang.Object)
  +     */
  +    public void setAttribute(String key, Object value)
  +    {
  +        requestAttributes.put(key, value);
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getAttribute(java.lang.String)
  +     */
  +    public Object getAttribute(String key)
       {
  -        return requestAttributes.get(key);        
  +        return requestAttributes.get(key);    
       }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.jetspeed.request.RequestContext#getPath()
  +     */
  +    public String getPath()
  +    {
  +        return path;
  +    }
  +    
   }
  
  
  
  1.3       +44 -27    jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/profiler/TestProfiler.java
  
  Index: TestProfiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/profiler/TestProfiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestProfiler.java	4 Dec 2003 04:52:09 -0000	1.2
  +++ TestProfiler.java	17 Dec 2003 20:46:34 -0000	1.3
  @@ -185,7 +185,7 @@
               }
               else
               {
  -                assertTrue("Unknown rule encountered: " + rule.getId(), false);            
  +                // assertTrue("Unknown rule encountered: " + rule.getId(), false);            
               }
                           
           }
  @@ -203,42 +203,42 @@
           while (criteria.hasNext())
           {
               RuleCriterion criterion = (RuleCriterion)criteria.next();
  -            assertTrue("standard criteria type", criterion.getType().equals("standard"));
  +            assertNotNull("criteria type ", criterion.getType());
               System.out.println("criteria name = " + criterion.getName());            
               switch (count)
               {
                   case 0:
  -                    assertTrue("standard criteria name " + criterion.getName(), 
  +                    assertTrue("criteria name " + criterion.getName(), 
                                   criterion.getName().equals(ProfilingRule.STANDARD_DESKTOP));
  -                    assertNotNull("standard criteria value", criterion.getValue());
  -                    assertTrue("standard criteria value", criterion.getValue().equals(DEFAULT_DESKTOP));
  +                    assertNotNull("criteria value", criterion.getValue());
  +                    assertTrue("criteria value", criterion.getValue().equals(DEFAULT_DESKTOP));
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                       break;                
                   case 1:
  -                    assertTrue("standard criteria name " + criterion.getName(), 
  +                    assertTrue("criteria name " + criterion.getName(), 
                                   criterion.getName().equals(ProfilingRule.STANDARD_PAGE));
  -                    assertNotNull("standard criteria value", criterion.getValue());
  -                    assertTrue("standard criteria value", criterion.getValue().equals(DEFAULT_PAGE));
  +                    assertNotNull("criteria value", criterion.getValue());
  +                    assertTrue("criteria value", criterion.getValue().equals(DEFAULT_PAGE));
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                       break;
                   case 2:
  -                    assertTrue("standard criteria name", criterion.getName().equals(ProfilingRule.STANDARD_GROUP_ROLE_USER));
  -                    assertNull("standard criteria value", criterion.getValue());
  +                    assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_USER));
  +                    assertNull("criteria value", criterion.getValue());
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                       break;
                   case 3:
  -                    assertTrue("standard criteria name", criterion.getName().equals(ProfilingRule.STANDARD_MEDIATYPE));
  -                    assertNull("standard criteria value", criterion.getValue());
  +                    assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_MEDIATYPE));
  +                    assertNull("criteria value", criterion.getValue());
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                       break;
                   case 4:
  -                    assertTrue("standard criteria name", criterion.getName().equals(ProfilingRule.STANDARD_LANGUAGE));
  -                    assertNull("standard criteria value", criterion.getValue());
  +                    assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_LANGUAGE));
  +                    assertNull("criteria value", criterion.getValue());
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                       break;
                   case 5:
  -                    assertTrue("standard criteria name", criterion.getName().equals(ProfilingRule.STANDARD_COUNTRY));
  -                    assertNull("standard criteria value", criterion.getValue());
  +                    assertTrue("criteria name", criterion.getName().equals(ProfilingRule.STANDARD_COUNTRY));
  +                    assertNull("criteria value", criterion.getValue());
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_CONTINUE);
                       break;                                    
               }   
  @@ -255,7 +255,7 @@
           while (criteria.hasNext())
           {
               RuleCriterion criterion = (RuleCriterion)criteria.next();
  -            assertTrue("fallback criteria type", criterion.getType().equals("standard"));
  +            assertNotNull("fallback criteria type", criterion.getType());
               
               switch (count)
               {
  @@ -272,7 +272,7 @@
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_STOP);
                       break;                    
                   case 2:
  -                    assertTrue("fallback criteria name", criterion.getName().equals(ProfilingRule.STANDARD_ROLE_FALLBACK));
  +                    assertTrue("fallback criteria name", criterion.getName().equals(ProfilingRule.STANDARD_ROLE));
                       assertNull("fallback criteria value", criterion.getValue());
                       assertTrue("fallback type", criterion.getFallbackType() == RuleCriterion.FALLBACK_LOOP);                    
                       break;
  @@ -311,14 +311,15 @@
           request.setMimeType("text/html");
           Map params = request.getParameterMap();
           params.put("page", "default-other");
  +        params.put("path", "/sports/football/nfl/chiefs");
           
           ProfileLocator locator = service.getProfile(request);
  -        assertNotNull("standard rule test on getProfile returned null", locator);
  +        assertNotNull("rule test on getProfile returned null", locator);
           String path = locator.getLocatorPath();
           System.out.println("locator = " + path);        
           assertTrue("locator key value unexpected: " + path, 
                       path.equals(
  -              "desktop/default-desktop/page/default-other/user/anon/mediatype/HTML/language/en/country/US"));
  +              "desktop:default-desktop:page:default-other:user:anon:mediatype:HTML:language:en:country:US"));
   
           // test fallback
           Iterator fallback = locator.iterator();
  @@ -331,20 +332,20 @@
                   case 0:
                       assertTrue("locatorPath[0]: " + locatorPath, 
                                   locatorPath.equals(
  -                        "desktop/default-desktop/page/default-other/user/anon/mediatype/HTML/language/en/country/US"));
  +                        "desktop:default-desktop:page:default-other:user:anon:mediatype:HTML:language:en:country:US"));
                       break;
                   case 1:
                       assertTrue("locatorPath[1]: " + locatorPath, 
                                   locatorPath.equals(
  -                         "desktop/default-desktop/page/default-other/user/anon/mediatype/HTML/language/en"));
  +                         "desktop:default-desktop:page:default-other:user:anon:mediatype:HTML:language:en"));
                       break;                
                   case 2:
                       assertTrue("locatorPath[2]: " + locatorPath, 
  -                                locatorPath.equals("desktop/default-desktop/page/default-other/user/anon/mediatype/HTML"));
  +                                locatorPath.equals("desktop:default-desktop:page:default-other:user:anon:mediatype:HTML"));
                       break;                
                   case 3:
                       assertTrue("locatorPath[3]: " + locatorPath, 
  -                                locatorPath.equals("desktop/default-desktop/page/default-other/user/anon"));
  +                                locatorPath.equals("desktop:default-desktop:page:default-other:user:anon"));
                       break;                
                   
               }
  @@ -362,7 +363,7 @@
           {
               String locatorPath = (String)fallback.next();
               assertTrue("locatorPath: " + locatorPath, 
  -                        locatorPath.equals("page/test"));
  +                        locatorPath.equals("page:test"));
               
               System.out.println("Simple Test: path = " + locatorPath);
               count++;            
  @@ -406,10 +407,26 @@
           // params.put("page", "default");
       
           ProfileLocator locator = service.getProfile(request);
  -        assertNotNull("standard rule test on getProfile returned null", locator);
  +        assertNotNull("rule test on getProfile returned null", locator);
           System.out.println("page = " + locator.getValue("page"));
           
           Page page = service.getPage(locator);
           assertNotNull("page is null", page);                
       }
  +   
  +    public void testPath() throws Exception
  +    {
  +        service = getService();               
  +        assertNotNull("profiler service is null", service);
  +
  +        PortalContext pc = Jetspeed.getContext();
  +        RequestContext request = new MockRequestContext(pc, "/football/nfl/chiefs");
  +        ProfilingRule rule = service.getRule("path");            
  +        ProfileLocator locator = service.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"));
  +    }
  +    
   }
  
  
  
  1.6       +1 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/ojb/repository_page.xml
  
  Index: repository_page.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/ojb/repository_page.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- repository_page.xml	4 Dec 2003 04:52:09 -0000	1.5
  +++ repository_page.xml	17 Dec 2003 20:46:34 -0000	1.6
  @@ -98,7 +98,7 @@
        jdbc-type="VARCHAR"
       />    
       <field-descriptor
  -     name="resolverName"
  +     name="name"
        column="NAME"
        jdbc-type="VARCHAR"
       />    
  
  
  
  1.14      +11 -12    jakarta-jetspeed-2/portal/src/webapp/WEB-INF/db/hsql/Registry.script
  
  Index: Registry.script
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/db/hsql/Registry.script,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Registry.script	8 Dec 2003 19:08:15 -0000	1.13
  +++ Registry.script	17 Dec 2003 20:46:34 -0000	1.14
  @@ -264,17 +264,16 @@
   INSERT INTO MEDIATYPE_TO_MIMETYPE VALUES(2,2)
   INSERT INTO MEDIATYPE_TO_MIMETYPE VALUES(3,3)
   INSERT INTO PROFILING_RULE VALUES('j1','org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule','The default profiling rule following the Jetspeed-1 hard-coded profiler fallback algorithm.')
  +INSERT INTO PROFILING_RULE VALUES('path','org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule','use a path to locate.')
   INSERT INTO PROFILING_RULE VALUES('role-fallback','org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule','A role based fallback algorithm based on Jetspeed-1 role-based fallback')
  -INSERT INTO RULE_CRITERION VALUES('1','j1',0,'standard','desktop','default-desktop',0)
  -INSERT INTO RULE_CRITERION VALUES('10','role-fallback',3,'standard','mediatype',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('11','role-fallback',4,'standard','language',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('12','role-fallback',5,'standard','country',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('2','j1',1,'standard','page','default-page',0)
  -INSERT INTO RULE_CRITERION VALUES('3','j1',2,'standard','group.role.user',NULL,0)
  -INSERT INTO RULE_CRITERION VALUES('4','j1',3,'standard','mediatype',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('5','j1',4,'standard','language',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('6','j1',5,'standard','country',NULL,1)
  -INSERT INTO RULE_CRITERION VALUES('7','role-fallback',0,'standard','desktop','default-desktop',0)
  -INSERT INTO RULE_CRITERION VALUES('8','role-fallback',1,'standard','page','default-page',0)
  -INSERT INTO RULE_CRITERION VALUES('9','role-fallback',2,'standard','roles',NULL,2)
  +INSERT INTO RULE_CRITERION VALUES('1','j1',0,'request.session','desktop','default-desktop',0)
  +INSERT INTO RULE_CRITERION VALUES('10','path',0,'path','path','/',0)
  +INSERT INTO RULE_CRITERION VALUES('2','j1',1,'request.session','page','default-page',0)
  +INSERT INTO RULE_CRITERION VALUES('3','j1',2,'group.role.user','user',NULL,0)
  +INSERT INTO RULE_CRITERION VALUES('4','j1',3,'mediatype','mediatype',NULL,1)
  +INSERT INTO RULE_CRITERION VALUES('5','j1',4,'language','language',NULL,1)
  +INSERT INTO RULE_CRITERION VALUES('6','j1',5,'country','country',NULL,1)
  +INSERT INTO RULE_CRITERION VALUES('7','role-fallback',0,'request.session','desktop','default-desktop',0)
  +INSERT INTO RULE_CRITERION VALUES('8','role-fallback',1,'request.session','page','default-page',0)
  +INSERT INTO RULE_CRITERION VALUES('9','role-fallback',2,'role','role',NULL,0)
   INSERT INTO PRINCIPAL_RULE_ASSOC VALUES('anon','j1')
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message