rogerrut 2004/12/02 16:57:20
Modified: components/jetspeed/src/java/org/apache/jetspeed/rewriter
WebContentRewriter.java
Log:
Make sure that:
<A> Href only get replaced with Portlet actions
any relative path is converted to a full URL
Revision Changes Path
1.5 +16 -28
jakarta-jetspeed-2/components/jetspeed/src/java/org/apache/jetspeed/rewriter/WebContentRewriter.java
Index: WebContentRewriter.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/jetspeed/src/java/org/apache/jetspeed/rewriter/WebContentRewriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebContentRewriter.java 2 Dec 2004 22:56:28 -0000 1.4
+++ WebContentRewriter.java 3 Dec 2004 00:57:20 -0000 1.5
@@ -60,13 +60,10 @@
*/
public String rewriteUrl(String url, String tag, String attribute)
{
- /*
- * TODO: no default. Use default Jetspeed JIRA to make sure that the
- * method was called
- */
- String modifiedURL =
"http://nagoya.apache.org/jira/secure/BrowseProject.jspa?id=10492";
- // Check if it's a relative or full URL
- if (url.startsWith("/") || url.indexOf("http") == -1)
+ String modifiedURL = url;
+
+ // Any relative URL needs to be converted to a full URL
+ if (url.startsWith("/") )
{
try
{
@@ -74,39 +71,30 @@
{
URL full = new URL(new URL(this.getBaseUrl()), url);
modifiedURL = full.toString();
- }
- else
- {
- modifiedURL = url; // leave as is
- }
+ }
+ else
+ {
+ modifiedURL = url; // leave as is
+ }
}
catch (Exception e)
{
modifiedURL = url;
}
}
- else
+
+ // Only add PortletActions to URL's which are anchors (tag=a) and
HREF's (attribute= HREF) -- ignore all others links
+ if ( tag.compareToIgnoreCase("A") == 0 &&
attribute.compareToIgnoreCase("HREF") == 0)
{
- // Apply action URL's not to images
- if (url.indexOf(".gif") == -1 && url.indexOf(".jpg") == -1)
- {
+ // Regular URL just add a portlet action
if (this.actionURL != null)
{
// create Action URL
- actionURL.setParameter(ACTION_PARAMETER_URL, url);
-
+ actionURL.setParameter(ACTION_PARAMETER_URL,
modifiedURL);
modifiedURL = actionURL.toString();
}
- else
- {
- modifiedURL = url;
- }
- }
- else
- {
- modifiedURL = url;
- }
}
+
return modifiedURL;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]