String contextPath = request.getContextPath();
String servletName = request.getServletPath();
// Construct portal URL using info retrieved from servlet request.
PortalURL portalURL = new RelativePortalURLImpl(contextPath, servletName, this);
// Support added for filter. Should we seperate into a different impl?
String pathInfo = request.getPathInfo();
if (pathInfo == null) {
if((servletName.indexOf(".jsp") != -1) && !servletName.endsWith(".jsp")) {
int idx = servletName.indexOf(".jsp")+".jsp".length();
pathInfo = servletName.substring(idx);
servletName = servletName.substring(0, idx);
portalURL = new RelativePortalURLImpl(contextPath, servletName, this);
} else {
return portalURL;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Parsing request pathInfo: " + pathInfo);
}
StringBuffer renderPath = new StringBuffer();
StringTokenizer st = new StringTokenizer(pathInfo, "/", false);
while (st.hasMoreTokens()) {
String token = st.nextToken();
// Part of the render path: append to renderPath.
if (!token.startsWith(PREFIX)) {
// renderPath.append(token);
//Fix for PLUTO-243
renderPath.append('/').append(token);
}
// Action window definition: portalURL.setActionWindow().
else if (token.startsWith(PREFIX + ACTION)) {
portalURL.setActionWindow(decodeControlParameter(token)[0]);
}
// Window state definition: portalURL.setWindowState().
else if (token.startsWith(PREFIX + WINDOW_STATE)) {
String[] decoded = decodeControlParameter(token);
portalURL.setWindowState(decoded[0], new WindowState(decoded[1]));
}
// Portlet mode definition: portalURL.setPortletMode().
else if (token.startsWith(PREFIX + PORTLET_MODE)) {
String[] decoded = decodeControlParameter(token);
portalURL.setPortletMode(decoded[0], new PortletMode(decoded[1]));
}
// Portal URL parameter: portalURL.addParameter().
else {
String value = null;
if (st.hasMoreTokens()) {
value = st.nextToken();
}
// Defect PLUTO-361
// ADDED
PortalURLParameter param = decodeParameter( token, value );
if( param != null )
{
portalURL.addParameter( param );
}
// REMOVED
// portalURL.addParameter(decodeParameter(token, value));
}
}
if (renderPath.length() > 0) {
portalURL.setRenderPath(renderPath.toString());
}
// Return the portal URL.
return portalURL;
}