[jboss-svn-commits] JBoss Portal SVN: r5242 - in trunk/wsrp/src/main/org/jboss/portal/wsrp: . consumer
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 21 19:26:50 EDT 2006
Author: chris.laprun at jboss.com
Date: 2006-09-21 19:26:48 -0400 (Thu, 21 Sep 2006)
New Revision: 5242
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPRewritingConstants.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
Log:
- JBPORTAL-1053: fixed.
- Improvements to resources handling.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2006-09-21 23:25:59 UTC (rev 5241)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2006-09-21 23:26:48 UTC (rev 5242)
@@ -22,6 +22,7 @@
package org.jboss.portal.wsrp;
+import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.MediaType;
@@ -30,6 +31,8 @@
import javax.activation.MimeTypeParseException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
/**
@@ -39,10 +42,28 @@
*/
public class WSRPResourceURL extends WSRPPortletURL
{
+ private final static Logger log = Logger.getLogger(WSRPResourceURL.class);
+
private URL resourceURL;
private boolean requiresRewrite = false;
+ private static final List SUPPORTED_RESOURCE_TYPES = new ArrayList(4);
+ static
+ {
+ SUPPORTED_RESOURCE_TYPES.add(MediaType.CSS);
+ SUPPORTED_RESOURCE_TYPES.add(MediaType.JS);
+ SUPPORTED_RESOURCE_TYPES.add(MediaType.TEXT);
+ try
+ {
+ SUPPORTED_RESOURCE_TYPES.add(MediaType.parseMimeType("image/*"));
+ }
+ catch (MimeTypeParseException e)
+ {
+ // shouldn't happen;
+ }
+ }
+
public WSRPResourceURL(Mode mode, WindowState windowState, boolean secure, URL resourceURL, boolean requiresRewrite)
{
super(mode, windowState, secure);
@@ -94,18 +115,29 @@
{
try
{
+ paramValue = URLTools.decodeXWWWFormURL(paramValue);
+
if (requiresRewrite)
{
- paramValue = URLTools.decodeXWWWFormURL(paramValue);
+ // fixme: do something...
+ log.debug("Required re-writing but this is not yet implemented...");
}
resourceURL = new URL(paramValue);
- MediaType mediaType = MediaType.parseMimeTypeByExtension(resourceURL.getFile());
- MediaType image = MediaType.parseMimeType("image/*");
- if (!image.isAllowedSubType(mediaType))
+ String file = resourceURL.getFile();
+
+ MediaType mediaType = null;
+ try
{
- throw new UnsupportedOperationException("We don't currently support resource URLs that are not images.");
+ mediaType = MediaType.parseMimeTypeByExtension(file);
}
+ catch (MimeTypeParseException e)
+ {
+ log.debug("Couldn't determine (based on extension) MIME type of file: " + file
+ + "\nRetrieving the associated resource will probably fail.");
+ }
+
+ isSupported(mediaType);
}
catch (MalformedURLException e)
{
@@ -113,11 +145,22 @@
iae.initCause(e);
throw iae;
}
- catch (MimeTypeParseException e)
+ }
+ }
+
+ private void isSupported(MediaType mediaType)
+ {
+ if (mediaType != null)
+ {
+ for (int i = 0; i < SUPPORTED_RESOURCE_TYPES.size(); i++)
{
- IllegalArgumentException iae = new IllegalArgumentException();
- iae.initCause(e);
- throw iae;
+ MediaType type = (MediaType)SUPPORTED_RESOURCE_TYPES.get(i);
+ if (!type.isAllowedSubType(mediaType))
+ {
+ log.debug("MIME type '" + mediaType
+ + "' is not currently supported. Retrieving the associated resource will probably fail.");
+ return;
+ }
}
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPRewritingConstants.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPRewritingConstants.java 2006-09-21 23:25:59 UTC (rev 5241)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPRewritingConstants.java 2006-09-21 23:26:48 UTC (rev 5242)
@@ -35,158 +35,151 @@
private static final String WSRP_REWRITE = "wsrp_rewrite";
/**
- * 10.2.1
- * <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a
- * token (wsrp_rewrite) both at the start (with a Ò?Ó appended to clearly delimit the start of the
- * name/value pairs).</p>
+ * 10.2.1 <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a token
+ * (wsrp_rewrite) both at the start (with a Ò?Ó appended to clearly delimit the start of the name/value pairs).</p>
*/
public static final String BEGIN_WSRP_REWRITE = WSRP_REWRITE + "?";
public static final int WSRP_REWRITE_PREFIX_LENGTH = 13;
/**
- * 10.2.1
- * <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a
- * token (wsrp_rewrite) at the end (proceeded by a Ò/Ó to form the end token) of the URL declaration.</p>
+ * 10.2.1 <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a token
+ * (wsrp_rewrite) at the end (proceeded by a Ò/Ó to form the end token) of the URL declaration.</p>
*/
public static final String END_WSRP_REWRITE = "/" + WSRP_REWRITE;
public static final int WSRP_REWRITE_SUFFIX_LENGTH = 13;
/**
- * 10.2.1.1 wsrp-urlType
- * <p>This parameter MUST be specified first when using the Consumer URL rewriting template and
- * the value selected from the following definitions. Well-known portlet URL parameter names that
- * are valid for only one wsrp-urlType are described relative to that wsrp-urlType while the
- * remainder are described later.</p>
+ * 10.2.1.1 wsrp-urlType <p>This parameter MUST be specified first when using the Consumer URL rewriting template and
+ * the value selected from the following definitions. Well-known portlet URL parameter names that are valid for only
+ * one wsrp-urlType are described relative to that wsrp-urlType while the remainder are described later.</p>
*/
public static final String URL_TYPE_NAME = "wsrp-urlType";
/**
- * 10.2.1.1.1 wsrp-urlType = blockingAction
- * <p>Activation of the URL will result in an invocation of performBlockingInteraction() on the
- * Portlet that generated the markup. All form parameters, submitted as query string
- * parameters using the HTTP GET method, that are not used to encode parameters defined
- * by this specification MUST be passed to performBlockingInteraction() as
- * formParameters.</p>
+ * 10.2.1.1.1 wsrp-urlType = blockingAction <p>Activation of the URL will result in an invocation of
+ * performBlockingInteraction() on the Portlet that generated the markup. All form parameters, submitted as query
+ * string parameters using the HTTP GET method, that are not used to encode parameters defined by this specification
+ * MUST be passed to performBlockingInteraction() as formParameters.</p>
*/
public static final String URL_TYPE_BLOCKING_ACTION = "blockingAction";
/**
- * 10.2.1.1.2 wsrp-urlType = render
- * <p>Activation of the URL will result in an invocation of getMarkup(). This mechanism permits a
- * PortletÕs markup to contain URLs, which do not involve changes to local state, to avoid the
- * overhead of two-step processing by directly invoking getMarkup(). The URL MAY specify a
- * wsrp-navigationalState portlet URL parameter, whose value the Consumer MUST
- * supply in the navigationalState field of the MarkupParams structure. If there is no such
- * portlet URL parameter, the Consumer MUST NOT supply a value for this field.</p>
+ * 10.2.1.1.2 wsrp-urlType = render <p>Activation of the URL will result in an invocation of getMarkup(). This
+ * mechanism permits a PortletÕs markup to contain URLs, which do not involve changes to local state, to avoid the
+ * overhead of two-step processing by directly invoking getMarkup(). The URL MAY specify a wsrp-navigationalState
+ * portlet URL parameter, whose value the Consumer MUST supply in the navigationalState field of the MarkupParams
+ * structure. If there is no such portlet URL parameter, the Consumer MUST NOT supply a value for this field.</p>
*/
public static final String URL_TYPE_RENDER = "render";
/**
- * 10.2.1.1.3 wsrp-urlType = resource
- * <p>Activation of the URL will result in the Consumer acting as a gateway to the underlying
- * resource, possibly in a cached manner, and returning it to the user-agent. The URL for the
- * resource (including any query string parameters) is encoded as the value of the wsrp-url
- * parameter. When a portlet URL specifies ÒresourceÓ for the wsrp-urlType portlet URL
- * parameter, both the wsrp-url and wsrp-requiresRewrite portlet URL parameters MUST
- * also be specified. If the Portlet needs to share data with the referenced resource, it can
- * exploit the cookie support defined in section 10.4.</p>
+ * 10.2.1.1.3 wsrp-urlType = resource <p>Activation of the URL will result in the Consumer acting as a gateway to the
+ * underlying resource, possibly in a cached manner, and returning it to the user-agent. The URL for the resource
+ * (including any query string parameters) is encoded as the value of the wsrp-url parameter. When a portlet URL
+ * specifies ÒresourceÓ for the wsrp-urlType portlet URL parameter, both the wsrp-url and wsrp-requiresRewrite
+ * portlet URL parameters MUST also be specified. If the Portlet needs to share data with the referenced resource, it
+ * can exploit the cookie support defined in section 10.4.</p>
*/
public static final String URL_TYPE_RESOURCE = "resource";
/**
- * 10.2.1.1.3.1 wsrp-url
- * <p>This parameter provides the actual URL to the resource. Note that this needs to be an
- * absolute URL as the resource fetch will have no base for use in fetching a relative URL.
- * Also note that since this resource URL will appear as a parameter value, it has to be
- * strictly encoded (i.e. Ò&Ó, Ò=Ò, Ò/Ó, and Ò?Ó need to be url-escaped) so that special URL
- * characters do not invalidate the processing of the enclosing URL. Consumers are
- * encouraged to use the same communication style (e.g. HTTP Get or Post) for retrieving
- * the resource as was used in requesting the resource by the user-agent.</p>
+ * 10.2.1.1.3.1 wsrp-url <p>This parameter provides the actual URL to the resource. Note that this needs to be an
+ * absolute URL as the resource fetch will have no base for use in fetching a relative URL. Also note that since this
+ * resource URL will appear as a parameter value, it has to be strictly encoded (i.e. Ò&Ó, Ò=Ò, Ò/Ó, and Ò?Ó need to
+ * be url-escaped) so that special URL characters do not invalidate the processing of the enclosing URL. Consumers
+ * are encouraged to use the same communication style (e.g. HTTP Get or Post) for retrieving the resource as was used
+ * in requesting the resource by the user-agent.</p>
*/
public static final String RESOURCE_URL = "wsrp-url";
/**
- * 10.2.1.1.3.2 wsrp-requiresRewrite
- * <p>This boolean informs the Consumer that the resource needs to be parsed for URL
- * rewriting. Normally this means that there are names that will be cross-referenced
- * between the markup and this resource (e.g. JavaScript references). Note that this means
- * the Consumer needs to deal with rewriting unique ÒnamespacedÓ names in a set of
- * documents, rather than treating each document individually. Processing such resources
- * in a manner that allows caching of the resulting resource by the End-UserÕs user-agent
- * can improve the performance of the aggregated page for the End-User. In particular,
- * Consumers can process namespace rewriting by using a prefix that is unique to the
- * user/Portlet pair provided any such prefix is held constant for the duration of use within
- * the userÕs session with the Consumer of any one Portlet.</p>
+ * 10.2.1.1.3.2 wsrp-requiresRewrite <p>This boolean informs the Consumer that the resource needs to be parsed for
+ * URL rewriting. Normally this means that there are names that will be cross-referenced between the markup and this
+ * resource (e.g. JavaScript references). Note that this means the Consumer needs to deal with rewriting unique
+ * ÒnamespacedÓ names in a set of documents, rather than treating each document individually. Processing such
+ * resources in a manner that allows caching of the resulting resource by the End-UserÕs user-agent can improve the
+ * performance of the aggregated page for the End-User. In particular, Consumers can process namespace rewriting by
+ * using a prefix that is unique to the user/Portlet pair provided any such prefix is held constant for the duration
+ * of use within the userÕs session with the Consumer of any one Portlet.</p>
*/
public static final String RESOURCE_REQUIRES_REWRITE = "wsrp-requiresRewrite";
/**
- * 10.2.1.2 wsrp-navigationalState
- * <p>The value of this portlet URL parameter defines the navigational state the Consumer MUST
- * send to the Producer when the URL is activated. If this parameter is missing, the Consumer
- * MUST NOT supply the navigationalState field of the MarkupParams.</p>
+ * 10.2.1.2 wsrp-navigationalState <p>The value of this portlet URL parameter defines the navigational state the
+ * Consumer MUST send to the Producer when the URL is activated. If this parameter is missing, the Consumer MUST NOT
+ * supply the navigationalState field of the MarkupParams.</p>
*/
public static final String NAVIGATIONAL_STATE = "wsrp-navigationalState";
/**
- * 10.2.1.3 wsrp-interactionState
- * <p>The value of this portlet URL parameter defines the interaction state the Consumer MUST send
- * to the Producer when the URL is activated. Tree.If this parameter is missing, the Consumer MUST
+ * 10.2.1.3 wsrp-interactionState <p>The value of this portlet URL parameter defines the interaction state the
+ * Consumer MUST send to the Producer when the URL is activated. Tree.If this parameter is missing, the Consumer MUST
* NOT supply the interactionState field of the InteractionParams structure.</p>
*/
public static final String INTERACTION_STATE = "wsrp-interactionState";
/**
- * 10.2.1.4 wsrp-mode
- * <p>Activating this URL includes a request to change the mode parameter in MarkupParams into the
- * mode specified as the value for this portlet URL parameter. The value for wsrp-mode MUST be
- * one of the modes detailed in section 6.8 or a custom mode the Consumer specified as
- * supported during registration. The wsrp-mode portlet URL parameter MAY be used whenever
- * the wsrp-urlType portlet URL parameter has a value of ÒblockingActionÓ or ÒrenderÓ.</p>
+ * 10.2.1.4 wsrp-mode <p>Activating this URL includes a request to change the mode parameter in MarkupParams into the
+ * mode specified as the value for this portlet URL parameter. The value for wsrp-mode MUST be one of the modes
+ * detailed in section 6.8 or a custom mode the Consumer specified as supported during registration. The wsrp-mode
+ * portlet URL parameter MAY be used whenever the wsrp-urlType portlet URL parameter has a value of ÒblockingActionÓ
+ * or ÒrenderÓ.</p>
*/
public static final String MODE = "wsrp-mode";
/**
- * 10.2.1.5 wsrp-windowState
- * <p>Activating this URL includes a request to change the windowState parameter in MarkupParams
- * into the window state specified as the value for this portlet URL parameter. The value for wsrp-
- * windowState MUST be one of the values detailed in section 6.9 or a custom window state the
- * Consumer specified as supported during registration. The wsrp-windowState portlet URL
- * parameter MAY be used whenever the wsrp-urlType portlet URL parameter has a value of
- * ÒblockingActionÓ or ÒrenderÓ.</p>
+ * 10.2.1.5 wsrp-windowState <p>Activating this URL includes a request to change the windowState parameter in
+ * MarkupParams into the window state specified as the value for this portlet URL parameter. The value for wsrp-
+ * windowState MUST be one of the values detailed in section 6.9 or a custom window state the Consumer specified as
+ * supported during registration. The wsrp-windowState portlet URL parameter MAY be used whenever the wsrp-urlType
+ * portlet URL parameter has a value of ÒblockingActionÓ or ÒrenderÓ.</p>
*/
public static final String WINDOW_STATE = "wsrp-windowState";
/**
- * 10.2.1.6 wsrp-fragmentID
- * <p>This portlet URL parameter specifies the portion of an URL that navigates to a place within a
- * document.</p>
+ * 10.2.1.6 wsrp-fragmentID <p>This portlet URL parameter specifies the portion of an URL that navigates to a place
+ * within a document.</p>
*/
public static final String FRAGMENT_ID = "wsrp-fragmentID";
/**
- * 10.2.1.7 wsrp-secureURL
- * <p>The value for the wsrp-secureURL is a boolean indicating whether the resulting URL MUST involve
- * secure communication between the client and Consumer, as well as between the Consumer and Producer.
- * The default value of this boolean is ÒfalseÓ. Note that the ConsumerÕs aggregated page MUST be secure if
- * any of the Portlets whose content is being displayed on the page have indicated the need for secure
- * communication for their current markup.</p>
+ * 10.2.1.7 wsrp-secureURL <p>The value for the wsrp-secureURL is a boolean indicating whether the resulting URL MUST
+ * involve secure communication between the client and Consumer, as well as between the Consumer and Producer. The
+ * default value of this boolean is ÒfalseÓ. Note that the ConsumerÕs aggregated page MUST be secure if any of the
+ * Portlets whose content is being displayed on the page have indicated the need for secure communication for their
+ * current markup.</p>
*/
public static final String SECURE_URL = "wsrp-secureURL";
/**
- * 10.3.1 Consumer Rewriting (Namespace encoding)
- * <p>The Portlet can prefix the token with Òwsrp_rewrite_Ó. The Consumer will locate such markers
- * and MUST replace them with a prefix that is unique to this instance of this portlet on the page.
- * This prefix has been chosen such that the Consumer is able to do a single parse of the markup
- * to both locate such markers and the URL rewrite expressions described in section 10.2.1. In
- * addition, this prefix is legal for at least the JavaScript and VBScript scripting languages and
- * CSS class names. This permits the independent testing of most generated markup fragments.</p>
+ * 10.3.1 Consumer Rewriting (Namespace encoding) <p>The Portlet can prefix the token with Òwsrp_rewrite_Ó. The
+ * Consumer will locate such markers and MUST replace them with a prefix that is unique to this instance of this
+ * portlet on the page. This prefix has been chosen such that the Consumer is able to do a single parse of the markup
+ * to both locate such markers and the URL rewrite expressions described in section 10.2.1. In addition, this prefix
+ * is legal for at least the JavaScript and VBScript scripting languages and CSS class names. This permits the
+ * independent testing of most generated markup fragments.</p>
*/
public static final String WSRP_REWRITE_TOKEN = WSRP_REWRITE + "_";
+ /** Opening token for URL parameters. See 10.2.2. */
+ public static final String REWRITE_PARAMETER_OPEN = "{";
+
+ /** Closing token for URL parameters. See 10.2.2. */
+ public static final String REWRITE_PARAMETER_CLOSE = "}";
+
+ /** Encoded version of REWRITE_PARAMETER_OPEN */
+ static final String ENC_OPEN = "%7B";
+
+ /** Encoded version of REWRITE_PARAMETER_CLOSE */
+ static final String ENC_CLOSE = "%7D";
+
+ /* Constants for Resource URL processing */
+ public static final String FAKE_RESOURCE_START = "JBP_RES_REW=";
+ public static final String FAKE_RESOURCE_REQ_REW = "JBP_REQ_REW";
+ public static final String FAKE_RESOURCE_URL = FAKE_RESOURCE_START + "{wsrp-url}" + FAKE_RESOURCE_REQ_REW + "{wsrp-requiresRewrite}";
+
private WSRPRewritingConstants()
{
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-09-21 23:25:59 UTC (rev 5241)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-09-21 23:26:48 UTC (rev 5242)
@@ -459,32 +459,26 @@
return new Property(name, lang, stringValue, null);
}
- private static final String OPEN = "{";
- private static final String CLOSE = "}";
- private static final String ENC_OPEN = "%7B";
- private static final String ENC_CLOSE = "%7D";
- private static final String FAKE_RESOURCE_URL = "JBP_RES_REW={wsrp-url}REM{wsrp-requiresRewrite}";
-
private static final ActionURL ACTION_URL = new ActionURL()
{
public StateString getInteractionState()
{
- return StateString.createFrom(OPEN + WSRPRewritingConstants.INTERACTION_STATE + CLOSE);
+ return StateString.createFrom(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.INTERACTION_STATE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
public StateString getNavigationalState()
{
- return StateString.createFrom(OPEN + WSRPRewritingConstants.NAVIGATIONAL_STATE + CLOSE);
+ return StateString.createFrom(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.NAVIGATIONAL_STATE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
public Mode getMode()
{
- return Mode.create(OPEN + WSRPRewritingConstants.MODE + CLOSE);
+ return Mode.create(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.MODE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
public WindowState getWindowState()
{
- return WindowState.create(OPEN + WSRPRewritingConstants.WINDOW_STATE + CLOSE);
+ return WindowState.create(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.WINDOW_STATE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
};
@@ -492,17 +486,17 @@
{
public StateString getNavigationalState()
{
- return StateString.createFrom(OPEN + WSRPRewritingConstants.NAVIGATIONAL_STATE + CLOSE);
+ return StateString.createFrom(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.NAVIGATIONAL_STATE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
public Mode getMode()
{
- return Mode.create(OPEN + WSRPRewritingConstants.MODE + CLOSE);
+ return Mode.create(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.MODE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
public WindowState getWindowState()
{
- return WindowState.create(OPEN + WSRPRewritingConstants.WINDOW_STATE + CLOSE);
+ return WindowState.create(WSRPRewritingConstants.REWRITE_PARAMETER_OPEN + WSRPRewritingConstants.WINDOW_STATE + WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
}
};
@@ -524,8 +518,8 @@
templates.setSecureRenderTemplate(createTemplate(context, RENDER_URL, Boolean.TRUE));
//fix-me: deal with resources properly, create fake ones for now
- templates.setResourceTemplate(FAKE_RESOURCE_URL);
- templates.setSecureResourceTemplate(FAKE_RESOURCE_URL);
+ templates.setResourceTemplate(WSRPRewritingConstants.FAKE_RESOURCE_URL);
+ templates.setSecureResourceTemplate(WSRPRewritingConstants.FAKE_RESOURCE_URL);
return templates;
}
@@ -533,8 +527,8 @@
private static String createTemplate(PortletInvocationContext context, PortletURL url, Boolean secure)
{
String template = context.encodeURL(url, secure, null, true);
- template = Tools.replace(template, ENC_OPEN, OPEN);
- template = Tools.replace(template, ENC_CLOSE, CLOSE);
+ template = Tools.replace(template, WSRPRewritingConstants.ENC_OPEN, WSRPRewritingConstants.REWRITE_PARAMETER_OPEN);
+ template = Tools.replace(template, WSRPRewritingConstants.ENC_CLOSE, WSRPRewritingConstants.REWRITE_PARAMETER_CLOSE);
return template;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2006-09-21 23:25:59 UTC (rev 5241)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2006-09-21 23:26:48 UTC (rev 5242)
@@ -22,6 +22,7 @@
package org.jboss.portal.wsrp.consumer;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.URLTools;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -29,6 +30,7 @@
import org.jboss.portal.portlet.result.FragmentResult;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.wsrp.WSRPPortletURL;
+import org.jboss.portal.wsrp.WSRPResourceURL;
import org.jboss.portal.wsrp.WSRPRewritingConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.CacheControl;
@@ -164,14 +166,12 @@
rewriter.setSecure(invocation.getSecurityContext().isSecure());
String userId = invocation.getUserContext().getId();
rewriter.setAuthenticated(userId != null); // is this correct?
- return URLTools.replaceURLsBy(markup, rewriter);
+ markup = URLTools.replaceURLsBy(markup, rewriter);
}
- else
- {
- // means that the producer generated the URLs, so handle resources...
- ResourceURLRewriter rewriter = (ResourceURLRewriter)resourceURLRewriterLocal.get();
- return URLTools.replaceURLsBy(markup, rewriter);
- }
+
+ // means that the producer generated the URLs, so handle resources...
+ ResourceURLRewriter rewriter = (ResourceURLRewriter)resourceURLRewriterLocal.get();
+ return URLTools.replaceURLsBy(markup, rewriter);
}
private void cacheMarkupIfNeeded(MarkupContext markupContext, FragmentResult result)
@@ -194,6 +194,7 @@
private static class WSRPURLRewriter extends URLTools.URLReplacementGenerator
{
+ protected Logger log = Logger.getLogger(getClass());
private PortletInvocationContext context;
private Boolean secure;
private Boolean authenticated;
@@ -218,7 +219,15 @@
String urlAsString = currentMatch.getURLAsString();
if (urlAsString.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
{
- return context.encodeURL(WSRPPortletURL.create(urlAsString), secure, authenticated, true);
+ WSRPPortletURL portletURL = WSRPPortletURL.create(urlAsString);
+ if (portletURL instanceof WSRPResourceURL)
+ {
+ log.debug("URL '" + urlAsString + "' seems to refer to a resource which are not currently supported. " +
+ "Trying to use the raw URL but this probably won't work...");
+ return portletURL.toString();
+ }
+
+ return context.encodeURL(portletURL, secure, authenticated, true);
}
return urlAsString;
}
@@ -226,22 +235,26 @@
private static class ResourceURLRewriter extends URLTools.URLReplacementGenerator
{
+ protected Logger log = Logger.getLogger(getClass());
+
public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
{
String urlAsString = currentMatch.getURLAsString();
- String prefix = "JBP_RES_REW";
+ String prefix = WSRPRewritingConstants.FAKE_RESOURCE_START;
if (urlAsString.startsWith(prefix))
{
- int index = urlAsString.indexOf("REM");
- boolean requireRewrite = Boolean.valueOf(urlAsString.substring(index + 3)).booleanValue();
+ int index = urlAsString.indexOf(WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW);
+ String requireRewriteStr = urlAsString.substring(index + WSRPRewritingConstants.FAKE_RESOURCE_REQ_REW.length());
+ boolean requireRewrite = Boolean.valueOf(requireRewriteStr).booleanValue();
- urlAsString = urlAsString.substring(prefix.length() + 1, index);
+ urlAsString = urlAsString.substring(prefix.length(), index);
if (requireRewrite)
{
- urlAsString = URLTools.decodeXWWWFormURL(urlAsString);
+ // FIX-ME: do something
+ log.debug("Required re-writing but this is not yet implemented...");
}
}
- return urlAsString;
+ return URLTools.decodeXWWWFormURL(urlAsString);
}
}
}
More information about the jboss-svn-commits
mailing list