ate 2004/10/17 07:02:38
Modified: portal/src/java/org/apache/jetspeed/container/url/impl
AbstractPortalURL.java
PathInfoEncodingPortalURL.java
QueryStringEncodingPortalURL.java
portal/src/java/org/apache/jetspeed/container/state/impl
JetspeedNavigationalStateComponent.java
portal/src/java/org/apache/jetspeed/request
JetspeedRequestContext.java
JetspeedRequestContextComponent.java
portal/src/webapp/WEB-INF/assembly pipelines.xml
jetspeed-spring.xml
jetspeed-api/src/java/org/apache/jetspeed/container/state
NavigationalStateComponent.java
portal/src/test/org/apache/jetspeed/pipeline
TestPipeline.java
jetspeed-api/src/java/org/apache/jetspeed/request
RequestContext.java
jetspeed-api/src/java/org/apache/jetspeed/mockobjects/request
MockRequestContext.java
portal/src/test/org/apache/jetspeed/container/state
TestNavigationalState.java
Added: portal/src/java/org/apache/jetspeed/container/url/impl
PortalURLValveImpl.java
Log:
See: http://issues.apache.org/jira/browse/JS2-149#action_54259
PortalURL instantiating is now done through a new PortalURLValveImpl, so that
CapabilityValveImpl can determine
the correct character encoding in time.
Furthermore, AbstractPortalURL dependency on RequestContext is removed to allow
easier integration of Fusion.
Revision Changes Path
1.12 +3 -6
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
Index: AbstractPortalURL.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractPortalURL.java 15 Oct 2004 21:44:31 -0000 1.11
+++ AbstractPortalURL.java 17 Oct 2004 14:02:38 -0000 1.12
@@ -26,7 +26,6 @@
import org.apache.jetspeed.container.ContainerConstants;
import org.apache.jetspeed.container.state.NavigationalState;
import org.apache.jetspeed.container.url.PortalURL;
-import org.apache.jetspeed.request.RequestContext;
import org.apache.pluto.om.window.PortletWindow;
/**
@@ -56,7 +55,7 @@
private boolean secure;
private String characterEncoding;
- public AbstractPortalURL(RequestContext context, NavigationalState navState)
+ public AbstractPortalURL(HttpServletRequest request, String characterEncoding,
NavigationalState navState)
{
if ( navStateParameter == null )
{
@@ -66,10 +65,8 @@
}
this.navState = navState;
- this.characterEncoding = context.getCharacterEncoding();
+ this.characterEncoding = characterEncoding;
- HttpServletRequest request = context.getRequest();
-
if (null != request)
{
decodeBaseURL(request);
1.2 +3 -4
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java
Index: PathInfoEncodingPortalURL.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PathInfoEncodingPortalURL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PathInfoEncodingPortalURL.java 15 Oct 2004 21:44:31 -0000 1.1
+++ PathInfoEncodingPortalURL.java 17 Oct 2004 14:02:38 -0000 1.2
@@ -20,7 +20,6 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.request.RequestContext;
/**
* PathInfoEncodingPortalURL encodes the NavigationalState as PathInfo element
@@ -30,9 +29,9 @@
*/
public class PathInfoEncodingPortalURL extends AbstractPortalURL
{
- public PathInfoEncodingPortalURL(RequestContext context, NavigationalState
navState)
+ public PathInfoEncodingPortalURL(HttpServletRequest request, String
characterEncoding, NavigationalState navState)
{
- super(context, navState);
+ super(request, characterEncoding, navState);
}
protected void decodePathAndNavigationalState(HttpServletRequest request)
1.2 +3 -4
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/QueryStringEncodingPortalURL.java
Index: QueryStringEncodingPortalURL.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/QueryStringEncodingPortalURL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- QueryStringEncodingPortalURL.java 15 Oct 2004 21:44:31 -0000 1.1
+++ QueryStringEncodingPortalURL.java 17 Oct 2004 14:02:38 -0000 1.2
@@ -18,7 +18,6 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.request.RequestContext;
/**
* QueryStringEncodingPortalURL encodes the NavigationalState as query parameter
@@ -28,9 +27,9 @@
*/
public class QueryStringEncodingPortalURL extends AbstractPortalURL
{
- public QueryStringEncodingPortalURL(RequestContext context, NavigationalState
navState)
+ public QueryStringEncodingPortalURL(HttpServletRequest request, String
characterEncoding, NavigationalState navState)
{
- super(context, navState);
+ super(request, characterEncoding, navState);
}
protected void decodePathAndNavigationalState(HttpServletRequest request)
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java
Index: PortalURLValveImpl.java
===================================================================
/*
* Copyright 2000-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.container.url.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.Jetspeed;
import org.apache.jetspeed.container.state.NavigationalStateComponent;
import org.apache.jetspeed.pipeline.PipelineException;
import org.apache.jetspeed.pipeline.valve.AbstractValve;
import org.apache.jetspeed.pipeline.valve.ValveContext;
import org.apache.jetspeed.request.RequestContext;
/**
* Creates the PortalURL for the current Request
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ate Douma</a>
* @version $Id: PortalURLValveImpl.java,v 1.1 2004/10/17 14:02:38 ate Exp $
*/
public class PortalURLValveImpl extends AbstractValve
{
private static final Log log = LogFactory.getLog(PortalURLValveImpl.class);
public void invoke(RequestContext request, ValveContext context)
throws PipelineException
{
try
{
if ( request.getPortalURL() == null )
{
NavigationalStateComponent navComponent =
(NavigationalStateComponent)Jetspeed.getComponentManager()
.getComponent(NavigationalStateComponent.class);
request.setPortalURL(navComponent.createURL(request.getRequest(),
request.getCharacterEncoding()));
}
}
catch (Exception e)
{
throw new PipelineException(e);
}
// Pass control to the next Valve in the Pipeline
context.invokeNext( request );
}
public String toString()
{
return "PortalURLValveImpl";
}
}
1.2 +5 -5
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
Index: JetspeedNavigationalStateComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JetspeedNavigationalStateComponent.java 15 Oct 2004 21:44:31 -0000 1.1
+++ JetspeedNavigationalStateComponent.java 17 Oct 2004 14:02:38 -0000 1.2
@@ -21,6 +21,7 @@
import javax.portlet.PortletMode;
import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,7 +31,6 @@
import org.apache.jetspeed.container.state.NavigationalState;
import org.apache.jetspeed.container.state.NavigationalStateComponent;
import org.apache.jetspeed.container.url.PortalURL;
-import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.util.ArgUtil;
/**
@@ -138,16 +138,16 @@
* @param context
* @return
*/
- public PortalURL createURL( RequestContext context )
+ public PortalURL createURL( HttpServletRequest request, String
characterEncoding )
{
PortalURL url = null;
try
{
- Constructor constructor = urlClass.getConstructor(new
Class[]{RequestContext.class,
+ Constructor constructor = urlClass.getConstructor(new
Class[]{HttpServletRequest.class, String.class,
NavigationalState.class});
- url = (PortalURL) constructor.newInstance(new Object[]{context,
create()});
+ url = (PortalURL) constructor.newInstance(new Object[]{request,
characterEncoding, create()});
return url;
}
catch (Exception e)
1.35 +10 -8
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.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- JetspeedRequestContext.java 15 Oct 2004 21:44:32 -0000 1.34
+++ JetspeedRequestContext.java 17 Oct 2004 14:02:38 -0000 1.35
@@ -30,7 +30,6 @@
import org.apache.jetspeed.Jetspeed;
import org.apache.jetspeed.aggregator.ContentDispatcher;
import org.apache.jetspeed.capabilities.CapabilityMap;
-import org.apache.jetspeed.container.state.NavigationalStateComponent;
import org.apache.jetspeed.container.url.PortalURL;
import org.apache.jetspeed.engine.servlet.ServletRequestFactory;
import org.apache.jetspeed.engine.servlet.ServletResponseFactory;
@@ -86,7 +85,7 @@
* @param config
*/
public JetspeedRequestContext( HttpServletRequest request, HttpServletResponse
response, ServletConfig config,
- NavigationalStateComponent navcomponent, UserInfoManager userInfoMgr )
+ UserInfoManager userInfoMgr )
{
this.request = request;
this.response = response;
@@ -100,12 +99,6 @@
{
this.request.setAttribute(RequestContext.REQUEST_PORTALENV, this);
}
-
- if (navcomponent != null)
- {
- url = navcomponent.createURL(this);
- }
-
}
private JetspeedRequestContext()
@@ -431,6 +424,15 @@
this.requestPath = getPortalURL().getPath();
}
return this.requestPath;
+ }
+
+ public void setPortalURL(PortalURL url)
+ {
+ if ( this.url != null )
+ throw new IllegalStateException("PortalURL already set");
+ if ( url == null )
+ throw new IllegalArgumentException("PortalURL may not be nullified");
+ this.url = url;
}
public PortalURL getPortalURL()
1.7 +5 -9
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
Index: JetspeedRequestContextComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JetspeedRequestContextComponent.java 15 Oct 2004 21:44:32 -0000 1.6
+++ JetspeedRequestContextComponent.java 17 Oct 2004 14:02:38 -0000 1.7
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.container.state.NavigationalStateComponent;
import org.apache.jetspeed.userinfo.UserInfoManager;
/**
@@ -37,20 +36,18 @@
{
private String contextClassName = null;
private Class contextClass = null;
- private NavigationalStateComponent nav;
/** The user info manager. */
private UserInfoManager userInfoMgr;
private final static Log log =
LogFactory.getLog(JetspeedRequestContextComponent.class);
- public JetspeedRequestContextComponent(NavigationalStateComponent nav, String
contextClassName)
+ public JetspeedRequestContextComponent(String contextClassName)
{
- this(nav, contextClassName, null);
+ this(contextClassName, null);
}
- public JetspeedRequestContextComponent(NavigationalStateComponent nav, String
contextClassName, UserInfoManager userInfoMgr)
+ public JetspeedRequestContextComponent(String contextClassName, UserInfoManager
userInfoMgr)
{
- this.nav = nav;
this.contextClassName = contextClassName;
this.userInfoMgr = userInfoMgr;
}
@@ -73,9 +70,8 @@
HttpServletRequest.class,
HttpServletResponse.class,
ServletConfig.class,
- NavigationalStateComponent.class,
UserInfoManager.class });
- context = (RequestContext) constructor.newInstance(new Object[] { req,
resp, config, nav, userInfoMgr });
+ context = (RequestContext) constructor.newInstance(new Object[] { req,
resp, config, userInfoMgr });
}
catch (Exception e)
1.5 +8 -0
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml
Index: pipelines.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pipelines.xml 18 Aug 2004 19:21:07 -0000 1.4
+++ pipelines.xml 17 Oct 2004 14:02:38 -0000 1.5
@@ -30,6 +30,11 @@
</constructor-arg>
</bean>
+ <bean id="portalURLValve"
+ class="org.apache.jetspeed.container.url.impl.PortalURLValveImpl"
+ init-method="initialize"
+ />
+
<bean id="securityValve"
class="org.apache.jetspeed.security.impl.SecurityValveImpl"
init-method="initialize"
@@ -106,6 +111,7 @@
<list>
<ref bean="localizationValve"/>
<ref bean="capabilityValve"/>
+ <ref bean="portalURLValve"/>
<ref bean="securityValve"/>
<ref bean="profilerValve"/>
<ref bean="containerValve"/>
@@ -127,6 +133,7 @@
<list>
<ref bean="localizationValve"/>
<ref bean="capabilityValve"/>
+ <ref bean="portalURLValve"/>
<ref bean="containerValve"/>
<ref bean="actionValve"/>
</list>
@@ -144,6 +151,7 @@
<list>
<ref bean="localizationValve"/>
<ref bean="capabilityValve"/>
+ <ref bean="portalURLValve"/>
<ref bean="containerValve"/>
<ref bean="portletValve"/>
</list>
1.26 +0 -1
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
Index: jetspeed-spring.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed-spring.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- jetspeed-spring.xml 15 Oct 2004 21:44:31 -0000 1.25
+++ jetspeed-spring.xml 17 Oct 2004 14:02:38 -0000 1.26
@@ -336,7 +336,6 @@
<bean id="org.apache.jetspeed.request.RequestContextComponent"
class="org.apache.jetspeed.request.JetspeedRequestContextComponent"
>
- <constructor-arg ><ref
bean="org.apache.jetspeed.container.state.NavigationalStateComponent"
/></constructor-arg>
<constructor-arg
><value>org.apache.jetspeed.request.JetspeedRequestContext</value></constructor-arg>
<constructor-arg ><ref bean="org.apache.jetspeed.userinfo.UserInfoManager"
/></constructor-arg>
</bean>
1.2 +5 -4
jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalStateComponent.java
Index: NavigationalStateComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/container/state/NavigationalStateComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NavigationalStateComponent.java 15 Oct 2004 21:41:43 -0000 1.1
+++ NavigationalStateComponent.java 17 Oct 2004 14:02:38 -0000 1.2
@@ -17,9 +17,9 @@
import javax.portlet.PortletMode;
import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
import org.apache.jetspeed.container.url.PortalURL;
-import org.apache.jetspeed.request.RequestContext;
/**
* NavigationalState
@@ -44,12 +44,13 @@
/**
* Creates a Portal URL representing the URL of the request.
*
- * @param context The ubiqitious request context.
+ * @param request The ubiqitious request.
+ * @param characterEncoding String containing the name of the chararacter
encoding
* @return A new Portal URL. This method will never return <code>null</code>;
* @throws FailedToCreatePortalUrlException if the portelt url could not be
created. Under normal
* circumstances, this should not happen.
*/
- PortalURL createURL(RequestContext context);
+ PortalURL createURL(HttpServletRequest request, String characterEncoding);
/**
* Given a window state name, look up its object.
1.15 +8 -7
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
Index: TestPipeline.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TestPipeline.java 18 Aug 2004 19:21:08 -0000 1.14
+++ TestPipeline.java 17 Oct 2004 14:02:38 -0000 1.15
@@ -79,12 +79,13 @@
Valve[] valves = pipeline.getValves();
assertTrue(valves[0].toString().equals("LocalizationValve"));
assertTrue(valves[1].toString().equals("CapabilityValveImpl"));
- assertTrue(valves[2].toString().equals("SecurityValve"));
- assertTrue(valves[3].toString().equals("ProfilerValve"));
- assertTrue(valves[4].toString().equals("ContainerValve"));
- assertTrue(valves[5].toString().equals("ActionValveImpl"));
- assertTrue(valves[6].toString().equals("AggregatorValve"));
- assertTrue(valves[7].toString().equals("CleanupValveImpl"));
+ assertTrue(valves[2].toString().equals("PortalURLValveImpl"));
+ assertTrue(valves[3].toString().equals("SecurityValve"));
+ assertTrue(valves[4].toString().equals("ProfilerValve"));
+ assertTrue(valves[5].toString().equals("ContainerValve"));
+ assertTrue(valves[6].toString().equals("ActionValveImpl"));
+ assertTrue(valves[7].toString().equals("AggregatorValve"));
+ assertTrue(valves[8].toString().equals("CleanupValveImpl"));
assertNotNull(engine.getPipeline("action-pipeline"));
assertNotNull(engine.getPipeline("portlet-pipeline"));
}
1.12 +10 -1
jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/request/RequestContext.java
Index: RequestContext.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/request/RequestContext.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- RequestContext.java 15 Oct 2004 21:41:43 -0000 1.11
+++ RequestContext.java 17 Oct 2004 14:02:38 -0000 1.12
@@ -164,6 +164,15 @@
public PortalURL getPortalURL();
/**
+ * Sets the Portal URL for the current request.
+ *
+ * @throws IllegalStateException if <code>portalUrl</code>
+ * has been set already.
+ * @throws IllegalArgumentException if a null value is passed in.
+ */
+ public void setPortalURL(PortalURL portalUrl);
+
+ /**
* Get the target Action Window
*
* @return PortletWindow The target portlet action window
1.6 +4 -1
jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/mockobjects/request/MockRequestContext.java
Index: MockRequestContext.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/mockobjects/request/MockRequestContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MockRequestContext.java 15 Oct 2004 21:41:43 -0000 1.5
+++ MockRequestContext.java 17 Oct 2004 14:02:38 -0000 1.6
@@ -61,7 +61,6 @@
private HttpServletResponse response;
private Object session;
-
/* (non-Javadoc)
* @see
org.apache.jetspeed.request.RequestContext#getUserInfoMap(org.apache.pluto.om.common.ObjectID)
*/
@@ -210,6 +209,10 @@
return null;
}
+ public void setPortalURL(PortalURL url)
+ {
+ }
+
/*
* (non-Javadoc)
*
1.2 +7 -5
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
Index: TestNavigationalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestNavigationalState.java 15 Oct 2004 21:44:32 -0000 1.1
+++ TestNavigationalState.java 17 Oct 2004 14:02:38 -0000 1.2
@@ -164,10 +164,11 @@
request.setPathInfo("stuff");
request.setRequestURI("/jetspeed/portal/stuff");
- JetspeedRequestContext context = new JetspeedRequestContext(request,
response, config, component, null );
+ JetspeedRequestContext context = new JetspeedRequestContext(request,
response, config, null );
// create base PortletURL
- PortalURL url = component.createURL(context);
+ PortalURL url = component.createURL(context.getRequest(),
context.getCharacterEncoding());
+ context.setPortalURL(url);
PortletWindow window = new PortletWindowImpl("111");
PortletWindow window2 = new PortletWindowImpl("222");
@@ -189,9 +190,10 @@
request.setPathInfo(portletURL.substring(portletURL.indexOf("/portal")+7));
}
- context = new JetspeedRequestContext(request, response, config, component,
null );
+ context = new JetspeedRequestContext(request, response, config, null );
- url = component.createURL(context);
+ url = component.createURL(context.getRequest(),
context.getCharacterEncoding());
+ context.setPortalURL(url);
NavigationalState nav = url.getNavigationalState();
// Check that they come out correctly
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]