You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by "Sahu, Santosh" <Sa...@ie.fid-intl.com> on 2006/08/24 17:33:23 UTC
Valves,
Folks,
Any help is appreciated.
I am trying to write my own valve and put it in the jetspeed piple line.
Question is I want to call this for every request and up on a conditions
success redirect to a page. What is the best option ? Is to use
response.sendRedirect or use PageProfiler to do the job.
If it is response.sendRedirect then when I need to call this valve in the
pipeline?
If it is Page profiler when I need to call.
Code:
public void invoke(RequestContext request, ValveContext context) throws
PipelineException
{
log.info("in Invoke -TCValveImpl");
try
{
//Get the Authenticated Used Id
//If(userId not null){
//Call ITermsAndConditions to check the whether this user
accepted TC
//if Accepted {
//context.invokeNext(request);
//}
//else
HttpServletResponse resp = request.getResponse();
String basePath=request.getPortalURL().getBasePath();
//Get the LoginPage PSML file name from property file (can
be from spring xml files)
resp.sendRedirect(basePath+"/login.psml");
}catch(Exception e)
{
e.printStackTrace();
}
}
RE: Valves,
Posted by Scott T Weaver <sc...@binary-designs.net>.
Personally, I use response.sendRedirect for my custom security valve which
redirects users to a federated login page. Here is my pipleing config:
<bean id="ugs-webkey-pipeline"
class="org.apache.jetspeed.pipeline.JetspeedPipeline"
init-method="initialize"
>
<constructor-arg>
<value>UGSWebkeyPipeline</value>
</constructor-arg>
<constructor-arg>
<list>
<ref bean="webkeyValve"/>
<ref bean="localeSelectorValve" />
<ref bean="localizationValve"/>
<ref bean="capabilityValve"/>
<ref bean="portalURLValve"/>
<ref bean="profilerValve"/>
<ref bean="customizerValve"/>
<ref bean="containerValve"/>
<ref bean="actionValve"/>
<ref bean="DecorationValve" />
<ref bean="aggregatorValve"/>
<ref bean="cleanUpValve"/>
</list>
</constructor-arg>
</bean>
As for the position in the pipeline, you can see mine is the first valve.
For redirects, you should be able to do this prior to the response being
committed. I am not entirely sure which valve in the default J2 pipeline
commits the response, but I am guessing it happens in one of these:
aggregatorValve, actionValve or conatinerValve.
-scott
> -----Original Message-----
> From: Sahu, Santosh [mailto:Santosh.Sahu@ie.fid-intl.com]
> Sent: Thursday, August 24, 2006 11:33 AM
> To: 'Jetspeed Developers List'
> Subject: Valves,
>
>
> Folks,
> Any help is appreciated.
> I am trying to write my own valve and put it in the jetspeed piple line.
>
> Question is I want to call this for every request and up on a conditions
> success redirect to a page. What is the best option ? Is to use
> response.sendRedirect or use PageProfiler to do the job.
> If it is response.sendRedirect then when I need to call this valve in the
> pipeline?
> If it is Page profiler when I need to call.
>
> Code:
> public void invoke(RequestContext request, ValveContext context) throws
> PipelineException
> {
> log.info("in Invoke -TCValveImpl");
> try
> {
> //Get the Authenticated Used Id
> //If(userId not null){
> //Call ITermsAndConditions to check the whether this user
> accepted TC
> //if Accepted {
> //context.invokeNext(request);
> //}
> //else
> HttpServletResponse resp = request.getResponse();
> String basePath=request.getPortalURL().getBasePath();
> //Get the LoginPage PSML file name from property file (can
> be from spring xml files)
> resp.sendRedirect(basePath+"/login.psml");
> }catch(Exception e)
> {
> e.printStackTrace();
> }
> }
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org