taylor 2004/01/19 15:40:02 Modified: portal maven.xml portal/src/java/org/apache/jetspeed/profiler/rules RuleCriterionResolver.java portal/src/java/org/apache/jetspeed/profiler/rules/impl AbstractProfilingRule.java RequestSessionResolver.java portal/src/java/org/apache/jetspeed/request JetspeedRequestContext.java portal/src/sql/hsql populate-db-default.sql portal/src/test/org/apache/jetspeed/profiler TestProfiler.java Added: portal/src/java/org/apache/jetspeed/profiler/rules/impl PathSessionResolver.java Log: Changed the PRofiler to use the URL Path to locate the page, not request parameters This has enabled me to run the testsuite in a different page Revision Changes Path 1.31 +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.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- maven.xml 15 Jan 2004 04:14:00 -0000 1.30 +++ maven.xml 19 Jan 2004 23:40:01 -0000 1.31 @@ -4,7 +4,7 @@ xmlns:reactor="reactor"> <!-- Target of maven test:single test --> -<property name='testcase' value='org.apache.jetspeed.container.TestPortletURL'/> +<property name='testcase' value='org.apache.jetspeed.profiler.TestProfiler'/> <!-- <goal name="jaxb:portlet" 1.3 +6 -3 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RuleCriterionResolver.java 17 Dec 2003 20:46:33 -0000 1.2 +++ RuleCriterionResolver.java 19 Jan 2004 23:40:01 -0000 1.3 @@ -64,10 +64,10 @@ * @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"; @@ -102,6 +102,9 @@ /** resolve the parameter via the request path, then value */ public static final String PATH = "path"; + + /** look in the request path first, then session */ + public static final String PATH_SESSION = "path.session"; /** * Resolver the value for a criterion. 1.5 +2 -1 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractProfilingRule.java 17 Dec 2003 20:46:34 -0000 1.4 +++ AbstractProfilingRule.java 19 Jan 2004 23:40:01 -0000 1.5 @@ -88,6 +88,7 @@ resolvers.put(RuleCriterionResolver.REQUEST, new StandardResolver()); resolvers.put(RuleCriterionResolver.REQUEST_SESSION, new RequestSessionResolver()); resolvers.put(RuleCriterionResolver.PATH, new PathResolver()); + resolvers.put(RuleCriterionResolver.PATH_SESSION, new PathSessionResolver()); resolvers.put(RuleCriterionResolver.HARD_CODED, new HardCodedResolver()); resolvers.put(RuleCriterionResolver.USER, new UserCriterionResolver()); resolvers.put(RuleCriterionResolver.ROLE, new RoleCriterionResolver()); 1.2 +3 -3 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RequestSessionResolver.java Index: RequestSessionResolver.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RequestSessionResolver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RequestSessionResolver.java 17 Dec 2003 20:46:34 -0000 1.1 +++ RequestSessionResolver.java 19 Jan 2004 23:40:01 -0000 1.2 @@ -73,8 +73,8 @@ 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()); + String key = this.getClass() + "." + criterion.getName(); + value = (String)context.getSessionAttribute(key); if (value == null) { value = criterion.getValue(); 1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/PathSessionResolver.java Index: PathSessionResolver.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 [EMAIL PROTECTED] * * 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; /** * PathSessionResolver * * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a> * @version $Id: PathSessionResolver.java,v 1.1 2004/01/19 23:40:01 taylor Exp $ */ public class PathSessionResolver 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.getPath(); if (value == null) { String key = this.getClass() + "." + criterion.getName(); value = (String)context.getSessionAttribute(key); if (value == null) { value = criterion.getValue(); } } return value; } } 1.9 +33 -3 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JetspeedRequestContext.java 31 Dec 2003 09:46:35 -0000 1.8 +++ JetspeedRequestContext.java 19 Jan 2004 23:40:01 -0000 1.9 @@ -55,6 +55,7 @@ import java.util.Locale; import java.util.Map; +import java.util.StringTokenizer; import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; @@ -103,7 +104,7 @@ private PortalURL requestedPortalURL; private PortletWindow actionWindow; private String encoding; - + public final static String REQUEST_PORTALENV = "org.apache.jetspeed.request.RequestContext"; /** @@ -434,6 +435,35 @@ */ public String getPath() { - return request.getPathInfo(); + String pathInfo = request.getPathInfo(); + if (pathInfo == null) + { + return null; + } + StringTokenizer tokenizer = new StringTokenizer(pathInfo, "/"); + StringBuffer path = new StringBuffer(); + int mode = 0; // 0=navigation, 1=control information + int count = 0; + String name = null; + while (tokenizer.hasMoreTokens()) + { + String token = tokenizer.nextToken(); + if (PortalControlParameter.isControlParameter(token)) + { + break; + } + if (count > 0) + { + path.append("/"); + } + path.append(token); + count++; + } + String result = path.toString(); + if (result.equals("/") || result.trim().length() == 0) + { + return null; + } + return result; } } 1.11 +1 -1 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- populate-db-default.sql 8 Jan 2004 21:21:31 -0000 1.10 +++ populate-db-default.sql 19 Jan 2004 23:40:02 -0000 1.11 @@ -265,7 +265,7 @@ 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, 'request.session', 'page', 'default-page', 0); +insert into RULE_CRITERION values (1, 'j1', 0, 'path.session', 'page', 'default-page', 0); insert into RULE_CRITERION values (2, 'j1', 1, 'group.role.user', 'user', null, 0); insert into RULE_CRITERION values (3, 'j1', 2, 'mediatype', 'mediatype', null, 1); insert into RULE_CRITERION values (4, 'j1', 3, 'language', 'language', null, 1); 1.5 +2 -2 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestProfiler.java 8 Jan 2004 21:02:37 -0000 1.4 +++ TestProfiler.java 19 Jan 2004 23:40:02 -0000 1.5 @@ -289,7 +289,7 @@ assertNotNull("profiler service is null", service); PortalContext pc = Jetspeed.getContext(); - RequestContext request = new MockRequestContext(pc); + RequestContext request = new MockRequestContext(pc, "default-other"); request.setSubject(createSubject("anon")); request.setLocale(new Locale("en", "US"));
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]