Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/igor/dev/stuff/svnbackup/trunk@5587 ef7698a4-5110-0410-9fc6-c7eb3693863f
  • Loading branch information
seb committed Oct 30, 2010
1 parent be65c76 commit 257468b
Showing 1 changed file with 24 additions and 32 deletions.
Expand Up @@ -71,6 +71,22 @@ public class WicketFilterPortletContext
'8', '7', '6', '5', '4', '3', '2', '1', 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r',
'q', 'p', 'o', 'm', 'n', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a' };

/**
* If the pathInfo starts with the portlet window id namespace prefix, remove it.
*
* @param pathInfo
* @return the pathInfo without the portlet window id namespace prefix
*/
private String _stripWindowIdFromPathInfo(String pathInfo)
{
if (pathInfo != null && pathInfo.startsWith(getServletResourceUrlPortletWindowIdPrefix()))
{
final int nextPath = pathInfo.indexOf('/', 1);
pathInfo = nextPath > -1 ? pathInfo.substring(nextPath) : null;
}
return pathInfo;
}

/**
* Factory method which will delegate to
* {@link #newPortletRequestContext(ServletWebRequest, WebResponse)} to create the
Expand All @@ -92,20 +108,18 @@ public boolean createPortletRequestContext(final ServletWebRequest request,
}

/**
* FIXME javadoc
*
* Try to extract the portlet's window id from the request url.
* Try to extract the portlet's window id from the request URL.
*
* @param pathInfo
* the url relative to the servlet context and filter path
* the URL relative to the servlet context and filter path
* @return the window id, or null if it couldn't be decoded, with no leading forward slash
*/
public String decodePortletWindowId(final String pathInfo)
{
String portletWindowId = null;
// the path info should start with the window id prefix
if (pathInfo != null && pathInfo.startsWith(getServletResourceUrlPortletWindowIdPrefix()))
{
String portletWindowId = null;
final int nextPath = pathInfo.indexOf('/', 1);
if (nextPath > -1)
portletWindowId = pathInfo.substring(
Expand All @@ -123,13 +137,10 @@ public String decodePortletWindowId(final String pathInfo)
if (slashEncoder != ':')
portletWindowId = portletWindowId.replace(slashEncoder, '/');
}
return portletWindowId;
}
else
// pathInfo was empty or didn't start with the window id prefix
{
// ignore - returns null
}
return portletWindowId;

return null;
}

/**
Expand Down Expand Up @@ -175,6 +186,7 @@ public String getServletResourceUrlPortletWindowIdPrefix()
return SERVLET_RESOURCE_URL_PORTLET_WINDOW_ID_PREFIX;
}


/**
* Overrides render strategy and adds the {@link PortletInvalidMarkupFilter} filter.
*
Expand All @@ -193,7 +205,6 @@ public void initFilter(final FilterConfig filterConfig, final WebApplication web
.addResponseFilter(new PortletInvalidMarkupFilter());
}


/**
* Factory method to create the {@link PortletRequestContext}.
*
Expand Down Expand Up @@ -258,30 +269,11 @@ public boolean setupFilter(final FilterConfig config,
{
final HttpSession proxiedSession = ServletPortletSessionProxy.createProxy(request,
portletWindowId);
pathInfo = stripWindowIdFromPathInfo(pathInfo);
pathInfo = _stripWindowIdFromPathInfo(pathInfo);
filterRequestContext.setRequest(new PortletServletRequestWrapper(context, request,
proxiedSession, filterPath, pathInfo));
}
}
return inPortletContext;
}

/**
* FIXME javadoc
*
* <p>
* If the pathInfo contains the portlet window id namespace prefix, remove it.
*
* @param pathInfo
* @return
*/
public String stripWindowIdFromPathInfo(String pathInfo)
{
if (pathInfo != null && pathInfo.startsWith(getServletResourceUrlPortletWindowIdPrefix()))
{
final int nextPath = pathInfo.indexOf('/', 1);
pathInfo = nextPath > -1 ? pathInfo.substring(nextPath) : null;
}
return pathInfo;
}
}

0 comments on commit 257468b

Please sign in to comment.