Author: chris.laprun(a)jboss.com
Date: 2010-03-10 10:04:03 -0500 (Wed, 10 Mar 2010)
New Revision: 2110
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java
Log:
- Use constant for URL marking.
- Removed incorrect replacement of - by _. Thought it was needed by JS but it's only
needed in identifiers. Plus, the conversion was lossy.
- Use encodeXWWWFormURL instead of safeEncodeForHTMLId to encode URLs.
- Cleaned-up in preparation of reverting to previous handling of resource URLs for
release.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java 2010-03-10
14:55:56 UTC (rev 2109)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/RenderHandler.java 2010-03-10
15:04:03 UTC (rev 2110)
@@ -184,18 +184,18 @@
private String processMarkup(String markup, PortletInvocation invocation, boolean
needsRewriting)
{
-
if (needsRewriting)
{
// fix-me: how to deal with fragment header? => interceptor?
+
+ // Replace rewrite token by namespace
String prefix = getNamespaceFrom(invocation.getWindowContext());
markup = TextTools.replace(markup, WSRPRewritingConstants.WSRP_REWRITE_TOKEN,
prefix);
+
URLFormat format = new URLFormat(invocation.getSecurityContext().isSecure(),
invocation.getSecurityContext().isAuthenticated(), true, true);
- /*WSRPURLRewriter rewriter = new WSRPURLRewriter(invocation.getContext(),
format, consumer);
- markup = URLTools.replaceURLsBy(markup, rewriter);*/
-
+ // replace URL marked for rewriting by proper ones
markup = TextTools.replaceBoundedString(markup,
WSRPRewritingConstants.BEGIN_WSRP_REWRITE,
WSRPRewritingConstants.END_WSRP_REWRITE, new
ResourceURLStringReplacementGenerator(invocation.getContext(), format, consumer), true,
false);
}
@@ -265,41 +265,33 @@
WSRPResourceURL resource = (WSRPResourceURL)portletURL;
- // get the parsed URL and add gtnresource to it so that the consumer can know
it needs to be intercepted
+ // get the parsed URL and add marker to it so that the consumer can know it
needs to be intercepted
URL url = resource.getResourceURL();
+ String query = url.getQuery();
+ if (ParameterValidation.isNullOrEmpty(query))
+ {
+ query = WSRPRewritingConstants.GTNRESOURCE;
+ }
+ else
+ {
+ query = "+" + WSRPRewritingConstants.GTNRESOURCE;
+ }
+
try
{
- String query = url.getQuery();
- if (ParameterValidation.isNullOrEmpty(query))
- {
- query = "gtnresource";
- }
- else
- {
- query = "+gtnresource";
- }
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(),
url.getPort(),
url.getPath(), query, url.getRef());
// set the resulting URI as the new resource ID, must be encoded as it
will be used in URLs
- String s = URLTools.safeEncodeForHTMLId(uri.toString());
- s = s.replace('-', '_');
+ String s = URLTools.encodeXWWWFormURL(uri.toString());
resource.setResourceId(s);
}
catch (Exception e)
{
- e.printStackTrace(); //To change body of catch statement use File |
Settings | File Templates.
+ throw new IllegalArgumentException("Cannot parse specified Resource
as a URI: " + url);
}
-
-
- /*// todo: this is a hack to circumvent frameworks that don't properly
request resource encoding (icefaces)
- if (resource.getResourceURL().toExternalForm().startsWith(SLASH))
- {
- return info.getEndpointConfigurationInfo().getRemoteHostAddress() +
match;
- }*/
}
-
return context.renderURL(portletURL, format);
}
}
Show replies by date