Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:51:37 -0400 (Thu, 10 Jul 2008)
New Revision: 11404
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
Log:
- Now deal with doubly encoded & (encoded as &). Not sure if this
should stay in...
- Improved error reporting.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10
11:51:22 UTC (rev 11403)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPActionURL.java 2008-07-10
11:51:37 UTC (rev 11404)
@@ -52,10 +52,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String
originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params,
WSRPRewritingConstants.INTERACTION_STATE);
if (paramValue != null)
{
@@ -68,7 +68,7 @@
{
navigationalState = new OpaqueStateString(paramValue);
params.remove(WSRPRewritingConstants.NAVIGATIONAL_STATE);
- }
+ }
}
protected String getURLType()
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10
11:51:22 UTC (rev 11403)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-07-10
11:51:37 UTC (rev 11404)
@@ -110,7 +110,7 @@
if (strict && portletURL instanceof WSRPPortletURL)
{
WSRPPortletURL other = (WSRPPortletURL)portletURL;
- url.setParams(other.extraParams);
+ url.setParams(other.extraParams, other.toString());
}
return url;
@@ -146,7 +146,7 @@
// find end token and extract it
int endTokenIndex = encodedURL.indexOf('/');
- if(endTokenIndex < 0)
+ if (endTokenIndex < 0)
{
throw new IllegalArgumentException(originalURL + " does not contain
" + WSRPRewritingConstants.END_WSRP_REWRITE);
}
@@ -168,10 +168,11 @@
// next param should be the url type
if (!encodedURL.startsWith(WSRPRewritingConstants.URL_TYPE_NAME + EQUALS))
{
- throw new IllegalArgumentException(encodedURL + " does not specify a URL
type.");
+ throw new IllegalArgumentException(originalURL + " does not specify a URL
type.");
}
// standardize parameter separators
+ encodedURL = Tools.replace(encodedURL, "&amp;", PARAM_SEPARATOR);
// sanitize doubly encoded & fix-me: should be removed?
encodedURL = Tools.replace(encodedURL, AMPERSAND, PARAM_SEPARATOR);
encodedURL = Tools.replace(encodedURL, "&", PARAM_SEPARATOR); // this
second shouldn't be used but in case it is...
@@ -197,7 +198,8 @@
}
else
{
- throw new IllegalArgumentException("Unrecognized URL type: " +
encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR)));
+ throw new IllegalArgumentException("Unrecognized URL type: " +
encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR))
+ + "in " + originalURL);
}
// other parameters
@@ -217,7 +219,7 @@
+ originalURL + "'");
}
- url.setParams(params);
+ url.setParams(params, originalURL);
url.setExtraParamsAfterEndToken(extraAfterEnd);
return url;
}
@@ -251,10 +253,10 @@
{
}
- protected final void setParams(Map<String, String> params)
+ protected final void setParams(Map<String, String> params, String originalURL)
{
// First extract specific parameters and remove them from the param map...
- dealWithSpecificParams(params);
+ dealWithSpecificParams(params, originalURL);
// ... then deal with extra params if in relaxed mode
if (!strict)
@@ -268,9 +270,10 @@
* Deal with specific parameters first so that we can remove them before dealing with
extra params. Sub-classes
* override to provide support for their specific parameters.
*
- * @param params name-value map of the URL parameters
+ * @param params name-value map of the URL parameters
+ * @param originalURL a String reprensenting the URL we are working with
*/
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String
originalURL)
{
// mode
String paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.MODE);
@@ -430,9 +433,17 @@
// extract param name
String name = param.substring(0, equalsIndex);
- if (strict && !name.startsWith("wsrp-"))
+ if (!name.startsWith("wsrp-"))
{
- throw new IllegalArgumentException("Invalid parameter name: '"
+ name + "'");
+ if (strict)
+ {
+ throw new IllegalArgumentException("Invalid parameter name in strict
validation mode (see documentation): '"
+ + name + "' in " + originalURL);
+ }
+ else
+ {
+ log.debug("Relaxed validation allowed invalid parameter name: "
+ name + " in " + originalURL);
+ }
}
// extract param value
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10
11:51:22 UTC (rev 11403)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPRenderURL.java 2008-07-10
11:51:37 UTC (rev 11404)
@@ -50,10 +50,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String
originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params,
WSRPRewritingConstants.NAVIGATIONAL_STATE);
if (paramValue != null)
{
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10
11:51:22 UTC (rev 11403)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2008-07-10
11:51:37 UTC (rev 11404)
@@ -96,10 +96,10 @@
}
@Override
- protected void dealWithSpecificParams(Map<String, String> params)
+ protected void dealWithSpecificParams(Map<String, String> params, String
originalURL)
{
- super.dealWithSpecificParams(params);
-
+ super.dealWithSpecificParams(params, originalURL);
+
String paramValue = getRawParameterValueFor(params,
WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE);
if (paramValue != null)
{
@@ -108,7 +108,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain
a value for the required "
- + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + "
parameter.");
+ + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in
" + originalURL);
}
paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_URL);
@@ -135,7 +135,7 @@
catch (MimeTypeParseException e)
{
log.debug("Couldn't determine (based on extension) MIME type of
file: " + file
- + "\nRetrieving the associated resource will probably
fail.");
+ + "\nRetrieving the associated resource will probably
fail.");
}
isSupported(mediaType);
@@ -148,7 +148,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain
a value for the required "
- + WSRPRewritingConstants.RESOURCE_URL + " parameter.");
+ + WSRPRewritingConstants.RESOURCE_URL + " parameter in " +
originalURL);
}
}
@@ -161,7 +161,7 @@
if (!type.isAllowedSubType(mediaType))
{
log.debug("MIME type '" + mediaType
- + "' is not currently supported. Retrieving the associated
resource will probably fail.");
+ + "' is not currently supported. Retrieving the
associated resource will probably fail.");
return;
}
}