You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2010/01/07 23:37:54 UTC
svn commit: r897040 - in /myfaces/portlet-bridge/core/trunk:
api/src/main/java/javax/portlet/faces/
impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/
impl/src/main/java/org/apache/myfaces/portlet/faces/context/
Author: mfreedman
Date: Thu Jan 7 22:37:53 2010
New Revision: 897040
URL: http://svn.apache.org/viewvc?rev=897040&view=rev
Log:
PORTLETBRIDGE-105: encodeResourceURL mishandles encoding portlet:render
PORTLETBRIDGE-104: GFP reads DEFAULT_CHARACTERSET_ENCODING/CHARENCODING from wrong initParam
PORTLETBRIDGE-103: Bridge.destroy fails to release ELContextListener.
Modified:
myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Modified: myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=897040&r1=897039&r2=897040&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Thu Jan 7 22:37:53 2010
@@ -312,8 +312,9 @@
/**
* Returns the default content type for this portlet request. Subclasses override to
- * alter the default behavior. Default implementation returns value of the portlet context init
- * parameter: javax.portlet.faces.DefaultContentType. If it doesn't exist the portlet
+ * alter the default behavior. Default implementation returns value of the portlet init
+ * parameter: javax.portlet.faces.DefaultContentType. If it doesn't exist or the value isn't in the
+ * lisst of requested types, the portlet
* request's preferred response content type is returned.
*
* Note: This support is specific to the Portlet 1.0 Bridge. Its value is
@@ -324,7 +325,7 @@
public String getResponseContentType(PortletRequest request)
{
String contentType =
- getPortletConfig().getPortletContext().getInitParameter(DEFAULT_CONTENT_TYPE);
+ getPortletConfig().getInitParameter(DEFAULT_CONTENT_TYPE);
if (contentType == null || !isInRequestedContentTypes(request, contentType))
{
@@ -348,7 +349,7 @@
/**
* Returns the character set encoding used for this portlet response. Subclasses override to
- * alter the default behavior. Default implementation returns value of the portlet context init
+ * alter the default behavior. Default implementation returns value of the portlet init
* parameter: javax.portlet.faces.DefaultCharacterSetEncoding. If it doesn't exist null
* is returned.
*
@@ -359,7 +360,7 @@
*/
public String getResponseCharacterSetEncoding(PortletRequest request)
{
- return getPortletConfig().getPortletContext().getInitParameter(DEFAULT_CHARACTERSET_ENCODING);
+ return getPortletConfig().getInitParameter(DEFAULT_CHARACTERSET_ENCODING);
}
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=897040&r1=897039&r2=897040&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Thu Jan 7 22:37:53 2010
@@ -714,6 +714,10 @@
mInitialized = false;
+ // Remove the context listener
+ ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
+ .getApplication().removeELContextListener(this);
+
// remove any scopes being managed for this portlet
// Each scope has a per portlet prefix -- pass in the prefix
// constructed by adding the prefix to an empty string.
Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=897040&r1=897039&r2=897040&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Thu Jan 7 22:37:53 2010
@@ -47,7 +47,6 @@
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
-import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
@@ -558,81 +557,106 @@
@Override
public String encodeResourceURL(String s)
{
- boolean containsBackLinkMarker = false, isViewLink = false;
-
- if (isOpaqueURL(s))
+ // Unfortunately at least the 1.2_03 version of Mojarra URL encodes resource links via
+ // h:outputLink with + rather than %20. This causes pluto to barf on teh subsequent request as
+ // it doesn't properly decode the incoming request into its parts. To work around this ensure
+ // no spaces exist in the returned url string
+ if (isPortletURL(s))
{
- return s;
+ return urlEncode(encodeResourceAsViewNavigationURL(s));
}
-
- if (s.indexOf(Bridge.BACK_LINK) != -1)
+ else if (isOpaqueURL(s))
{
- containsBackLinkMarker = true;
+ // spec says return this unchanged
+ return s;
}
-
- if (!isExternalURL(s))
+ else if (isExternalURL(s))
{
- // Only non-external URLs can be viewLinks
- isViewLink = isViewLink(s);
-
- if (!s.startsWith("/"))
- {
- // must be a relative path -- convert it to contextPath relative
- // construct our cwd (servletPath + pathInfo);
- String pi = null;
- String path = getRequestServletPath();
- if (path == null)
- {
- path = getRequestPathInfo();
- }
- else
- {
- pi = getRequestPathInfo();
- }
-
- if (pi != null)
- {
- path = path.concat(pi);
- }
-
- // remove target
- path = path.substring(0, path.lastIndexOf("/"));
- s = URLUtils.convertFromRelative(path, s);
- }
-
- if (!isViewLink)
- {
- // prepend the context path since portletResponse.encodeURL() requires a full path URI
- // Don't need to check return from getRequestContextPath because there must
- // always be a vlaue even if an empty string
- String ctxPath = getRequestContextPath();
- if (ctxPath.length() > 0 && !s.startsWith(ctxPath))
- {
- s = ctxPath + s;
- }
- }
+ return urlEncode(encodeResourceURL(s, false));
}
-
- // Check for backlink and viewlink markers -- if they exist replace
- if (containsBackLinkMarker || isViewLink)
+ else if (isViewLink(s))
{
- s = replaceResourceQueryStringMarkers(s, containsBackLinkMarker, isViewLink);
+ return urlEncode(encodeResourceAsViewNavigationURL(s));
}
-
- if (!isViewLink)
+ else
{
- s = mPortletResponse.encodeURL(s);
+ return urlEncode(encodeResourceURL(s, true));
}
- else
+ }
+
+ private String urlEncode(String s)
+ {
+ // replace all spaces in the url with %20 to avoid Faces from encoding with a +
+ return s.replace(" ", "%20");
+ }
+
+ private String encodeResourceURL(String s, boolean targetInApp)
+ {
+ if (targetInApp)
{
- s = encodeActionURL(s);
+ s = normalizeResourcePath(s);
}
+
+ // Check for backlink and viewlink markers -- if they exist replace
+ s = replaceResourceQueryStringMarkers(s);
+
+ // Some portlet containers implementing wsrp choose to separate the
+ // consumer rewrite string that represents this URL using & as the
+ // spec allows for either that or &. If the container has chosen to
+ // to do such -- undo it (use & instead) as faces renderkits/response writers
+ // may reencode when writing XMl content.
+ return mPortletResponse.encodeURL(s).replaceAll("\\&\\;", "&");
+ }
+
+ private String normalizeResourcePath(String s)
+ {
+ if (!s.startsWith("/"))
+ {
+ // must be a relative path -- convert it to contextPath relative
+ // construct our cwd (servletPath + pathInfo);
+ String pi = null;
+ String path = getRequestServletPath();
+ if (path == null)
+ {
+ path = getRequestPathInfo();
+ }
+ else
+ {
+ pi = getRequestPathInfo();
+ }
- // Avoid double encoding
- s = s.replaceAll("\\&\\;", "&");
+ if (pi != null)
+ {
+ path = path.concat(pi);
+ }
+ // remove target
+ path = path.substring(0, path.lastIndexOf("/"));
+ s = URLUtils.convertFromRelative(path, s);
+ }
+
+ // prepend the context path since portletResponse.encodeURL() requires a full path URI
+ // Don't need to check return from getRequestContextPath because there must
+ // always be a vlaue even if an empty string
+ String ctxPath = getRequestContextPath();
+ if (ctxPath.length() > 0 && !s.startsWith(ctxPath))
+ {
+ s = ctxPath + s;
+ }
+
return s;
}
+
+ private String encodeResourceAsViewNavigationURL(String s)
+ {
+ // Check for backlink and viewlink markers -- if they exist replace
+ s = replaceResourceQueryStringMarkers(s);
+
+ // encodeActionURL takes acre of & encoding issues
+ return encodeActionURL(s);
+ }
+
+
@Override
public void dispatch(String requestURI)
@@ -1404,9 +1428,8 @@
log("History for mode: " + mode + " : " + viewId);
}
-
- private String replaceResourceQueryStringMarkers(String s, boolean hasBackLink,
- boolean hasViewLink)
+
+ private String replaceResourceQueryStringMarkers(String s)
{
String path = null;
QueryString queryStr = null;
@@ -1424,7 +1447,7 @@
queryStr = new QueryString(s.substring(queryStart + 1), "UTF8");
path = s.substring(0, queryStart);
-
+
try
{
// If there is a backlink -- remove and convert it