Author: chris.laprun(a)jboss.com
Date: 2008-10-15 12:18:52 -0400 (Wed, 15 Oct 2008)
New Revision: 12070
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
Log:
- Replaced "magic" numbers for better robustness.
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-10-15
16:18:33 UTC (rev 12069)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2008-10-15
16:18:52 UTC (rev 12070)
@@ -152,7 +152,7 @@
}
encodedURL = encodedURL.substring(0, endTokenIndex)
- + encodedURL.substring(endTokenIndex +
WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
+ + encodedURL.substring(endTokenIndex +
WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
// remember that we should position the extra params after the end token
extraAfterEnd = true;
@@ -162,7 +162,7 @@
{
// remove prefix and suffix
encodedURL =
encodedURL.substring(WSRPRewritingConstants.WSRP_REWRITE_PREFIX_LENGTH,
- encodedURL.length() -
WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
+ encodedURL.length() - WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
}
// next param should be the url type
@@ -199,7 +199,7 @@
else
{
throw new IllegalArgumentException("Unrecognized URL type: " +
encodedURL.substring(0, encodedURL.indexOf(PARAM_SEPARATOR))
- + "in " + originalURL);
+ + "in " + originalURL);
}
// other parameters
@@ -208,7 +208,7 @@
if (encodedURL.length() > urlTypeLength)
{
// truncate again once the value is extracted
- encodedURL = encodedURL.substring(urlTypeLength + 1); // +1 for the param
separator
+ encodedURL = encodedURL.substring(urlTypeLength + PARAM_SEPARATOR.length());
// extract the other parameters
params = extractParams(encodedURL, originalURL, customModes,
customWindowStates);
@@ -216,7 +216,7 @@
else if (WSRPRewritingConstants.URL_TYPE_RESOURCE.equals(urlType))
{
throw new IllegalArgumentException("Both the 'wsrp-url' and
'wsrp-requiresRewrite' parameters MUST also be specified for resource URL
'"
- + originalURL + "'");
+ + originalURL + "'");
}
url.setParams(params, originalURL);
@@ -335,7 +335,7 @@
//
sb.append(WSRPRewritingConstants.BEGIN_WSRP_REWRITE).append(WSRPRewritingConstants.URL_TYPE_NAME)
- .append(EQUALS).append(getURLType());
+ .append(EQUALS).append(getURLType());
//
if (secure)
@@ -438,7 +438,7 @@
if (strict)
{
throw new IllegalArgumentException("Invalid parameter name in strict
validation mode (see documentation): '"
- + name + "' in " + originalURL);
+ + name + "' in " + originalURL);
}
else
{
@@ -447,7 +447,7 @@
}
// extract param value
- String value = param.substring(equalsIndex + 1, param.length()); // +1 to ignore
"="
+ String value = param.substring(equalsIndex + EQUALS.length(), param.length());
// check that the given mode is valid if the param is supposed to be one
if (WSRPRewritingConstants.MODE.equals(name))
@@ -462,7 +462,7 @@
}
params.put(name, value);
- encodedURL = encodedURL.substring(endParamIndex + 1); // +1 for the param
separator
+ encodedURL = encodedURL.substring(endParamIndex + PARAM_SEPARATOR.length());
}
return params;
}
Show replies by date