taylor 2004/03/15 15:03:16
Modified: src/java/org/apache/jetspeed/portal/portlets
RedirectPortlet.java
webapp/WEB-INF/conf JetspeedSecurity.properties
portlets.xreg
Log:
2 new Redirect portlet parameters:
parameterNames - Comma-separated list of query parameters names added to the URL,
matching session attributes names
sessionAttributeNames - Comma-separated list of session attributes to pass in as
Query Parameter Values
Revision Changes Path
1.4 +51 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/RedirectPortlet.java
Index: RedirectPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/RedirectPortlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RedirectPortlet.java 11 Mar 2004 01:04:28 -0000 1.3
+++ RedirectPortlet.java 15 Mar 2004 23:03:16 -0000 1.4
@@ -15,7 +15,6 @@
*/
package org.apache.jetspeed.portal.portlets;
-import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -28,6 +27,9 @@
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.services.statemanager.SessionState;
import org.apache.jetspeed.util.JetspeedClearElement;
+import org.apache.jetspeed.util.PortletConfigState;
+import org.apache.jetspeed.util.StringUtils;
+import org.apache.jetspeed.util.URIEncoder;
import org.apache.turbine.util.RunData;
/**
@@ -68,6 +70,7 @@
}
String url = this.getPortletConfig().getInitParameter("url");
+ url = createDynamicUrl((JetspeedRunData)rundata, url);
// rundata.setRedirectURI(url);
HttpServletRequest request = rundata.getRequest();
HttpServletResponse response = rundata.getResponse();
@@ -91,5 +94,51 @@
{
SessionState state =
((JetspeedRunData)rundata).getPortletSessionState(set.getID());
state.setAttribute(JetspeedResources.PATH_PANEID_KEY, null);
+ }
+
+ private String createDynamicUrl(JetspeedRunData rundata, String url)
+ {
+ String parameterNames = PortletConfigState.getParameter(this, rundata,
"parameterNames", null);
+ String sessionAttributeNames = PortletConfigState.getParameter(this,
rundata, "sessionAttributeNames", null);
+ if (parameterNames == null || sessionAttributeNames == null)
+ {
+ return url;
+ }
+
+ String[] names = StringUtils.stringToArray(parameterNames, ",");
+ String[] attribNames = StringUtils.stringToArray(sessionAttributeNames,
",");
+
+ if (names == null || attribNames == null)
+ {
+ return url;
+ }
+ if (names.length == 0 || attribNames.length == 0)
+ {
+ return url;
+ }
+ int count = (names.length > attribNames.length) ? names.length :
attribNames.length;
+ StringBuffer dynamic = new StringBuffer(url);
+ int appended = 0;
+ for(int ix=0; ix < count; ix++)
+ {
+ String attribute =
(String)rundata.getSession().getAttribute(attribNames[ix]);
+ if (attribute == null)
+ {
+ continue;
+ }
+ if (appended == 0)
+ {
+ dynamic.append("?");
+ }
+ else
+ {
+ dynamic.append("&");
+ }
+ appended++;
+ dynamic.append(URIEncoder.encode(names[ix]));
+ dynamic.append("=");
+ dynamic.append(URIEncoder.encode(attribute));
+ }
+ return dynamic.toString();
}
}
1.77 +0 -0 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.properties
Index: JetspeedSecurity.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedSecurity.properties,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
1.46 +14 -0 jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
Index: portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- portlets.xreg 3 Feb 2004 19:37:08 -0000 1.45
+++ portlets.xreg 15 Mar 2004 23:03:16 -0000 1.46
@@ -325,6 +325,20 @@
<description>Number (integer) of menus to clear the pane state
for</description>
</meta-info>
</parameter>
+ <parameter name="parameterNames" value="" hidden="false">
+ <meta-info>
+ <title>Query Parameter Names added to the URL</title>
+ <description>Comma-separated list of query parameters names added
to the URL, matching session attributes names list.</description>
+ </meta-info>
+ </parameter>
+ <parameter name="sessionAttributeNames" value="" hidden="false">
+ <meta-info>
+ <title>Session Attribute Names</title>
+ <description>Comma-separated list of session attributes to pass in
as Query Parameter Values</description>
+ </meta-info>
+ </parameter>
+
+
<category>web</category>
</portlet-entry>
</registry>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]