Author: julien(a)jboss.com
Date: 2008-01-18 04:58:02 -0500 (Fri, 18 Jan 2008)
New Revision: 9534
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java
Log:
start to implement public render parameter in PortletURL
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -22,15 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.impl.jsr168.api.PortletURLImpl;
-
import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletURL;
import javax.portlet.WindowState;
-import java.util.Iterator;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -42,90 +35,6 @@
public static final String SUFFIX = "snpbj";
/**
- * Check that provided map follow the constraints : <ul> <li>Not
null</li> <li>Keys are non null string</li>
- * <li>Values are non null string arrays</li> </ul> If a constraint
is not respected then an IllegalArgumentException
- * is thrown.
- *
- * @param map the map to check
- * @throws IllegalArgumentException
- */
- public static void checkPortletParameterMapValidity(Map map) throws
IllegalArgumentException
- {
- if (map == null)
- {
- throw new IllegalArgumentException("Map cannot be null");
- }
- for (Iterator i = map.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- Object key = entry.getKey();
- Object value = entry.getValue();
- if (key == null)
- {
- throw new IllegalArgumentException("Key cannot be null");
- }
- if (key instanceof String == false)
- {
- throw new IllegalArgumentException("Key must be a String and not "
+ key.getClass());
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- if (value instanceof String[] == false)
- {
- throw new IllegalArgumentException("Value must be a String[] and not
" + value.getClass());
- }
- }
- }
-
- /**
- * Check that the passed argument are non null otherwise throw an
IllegalArgumentException.
- *
- * @throws IllegalArgumentException
- */
- public static void checkPortletParameterValidity(String name, String value) throws
IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
- }
-
- /**
- * Check that the passed argument are non null otherwise throw an
IllegalArgumentException.
- *
- * @throws IllegalArgumentException
- */
- public static void checkPortletParameterValidity(String name, String[] values) throws
IllegalArgumentException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (values == null)
- {
- throw new IllegalArgumentException("Values cannot be null");
- }
- }
-
- /** Creates an action URL. */
- public static PortletURL createActionURL(PortletInvocation invocation, PortletRequest
preq)
- {
- return new PortletURLImpl(invocation, preq, new
PortletURLImpl.InternalActionURL());
- }
-
- /** Creates an render URL. */
- public static PortletURL createRenderURL(PortletInvocation invocation, PortletRequest
preq)
- {
- return new PortletURLImpl(invocation, preq, new
PortletURLImpl.InternalRenderURL());
- }
-
- /**
* Creates a <code>WindowState</code> object based on the specified name.
*
* @param windowStateName the name of the window state
@@ -182,7 +91,8 @@
/**
* Generates a namespace suitable for Portlet prefixing of tokens that need to be
unique in an aggregated page.
*
- * @param windowId
+ * @param windowId the window id
+ * @return the namespace value
* @since 2.6
*/
public static String generateNamespaceFrom(String windowId)
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -28,13 +28,11 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.BaseURL;
-import javax.portlet.PortletRequest;
import javax.portlet.WindowState;
import javax.portlet.PortletMode;
import javax.portlet.PortletSecurityException;
@@ -49,11 +47,26 @@
public abstract class BaseURLImpl implements BaseURL
{
+ public enum Type
+ {
+ ACTION, RENDER
+ }
+
+ public static PortletURLImpl createActionURL(PortletInvocation invocation,
PortletRequestImpl preq)
+ {
+ return new PortletURLImpl(invocation, preq, Type.ACTION);
+ }
+
+ public static PortletURLImpl createRenderURL(PortletInvocation invocation,
PortletRequestImpl preq)
+ {
+ return new PortletURLImpl(invocation, preq, Type.RENDER);
+ }
+
/** . */
protected PortletInvocation inv;
/** . */
- protected PortletRequest preq;
+ protected PortletRequestImpl preq;
/** . */
protected Boolean secure;
@@ -61,8 +74,25 @@
/** . */
protected InternalPortletURL url;
- public BaseURLImpl(PortletInvocation invocation, PortletRequest preq,
InternalPortletURL url)
+ protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type
type)
{
+ PortletParameterMap parameterMap = new PortletParameterMap(preq.navigationInfo);
+
+ //
+ InternalPortletURL url;
+ switch (type)
+ {
+ case ACTION:
+ url = new InternalActionURL(parameterMap);
+ break;
+ case RENDER:
+ url = new InternalRenderURL(parameterMap);
+ break;
+ default:
+ throw new AssertionError();
+ }
+
+ //
this.inv = invocation;
this.preq = preq;
this.url = url;
@@ -71,26 +101,17 @@
/** @throws IllegalArgumentException if the name is null */
public void setParameter(String name, String value)
{
- PortletUtils.checkPortletParameterValidity(name, value);
-
- //
- url.getInternalParameters().setValue(name, value);
+ url.parameters.setParameterValue(name, value);
}
public void setParameter(String name, String[] values)
{
- PortletUtils.checkPortletParameterValidity(name, values);
-
- //
- url.getInternalParameters().setValues(name, values);
+ url.parameters.setParameterValues(name, values);
}
public void setParameters(Map<String, String[]> parameters)
{
- PortletUtils.checkPortletParameterMapValidity(parameters);
-
- //
- url.getInternalParameters().replace(parameters);
+ url.parameters.setMap(parameters);
}
public void setSecure(boolean secure) throws PortletSecurityException
@@ -129,7 +150,7 @@
return responseContext.renderURL(url, secure, null, true);
}
- public static abstract class InternalPortletURL implements
org.jboss.portal.portlet.PortletURL
+ protected abstract class InternalPortletURL implements
org.jboss.portal.portlet.PortletURL
{
/** . */
@@ -138,6 +159,14 @@
/** . */
protected PortletMode portletMode;
+ /** . */
+ protected final PortletParameterMap parameters;
+
+ protected InternalPortletURL(PortletParameterMap parameters)
+ {
+ this.parameters = parameters;
+ }
+
public Mode getMode()
{
if (portletMode != null)
@@ -155,24 +184,19 @@
}
return null;
}
-
- protected abstract ParameterMap getInternalParameters();
}
- public static class InternalActionURL extends InternalPortletURL implements ActionURL
+ protected class InternalActionURL extends InternalPortletURL implements ActionURL
{
- /** . */
- private ParametersStateString parameters = new ParametersStateString();
-
- protected ParameterMap getInternalParameters()
+ private InternalActionURL(PortletParameterMap parameters)
{
- return parameters.getParameters();
+ super(parameters);
}
public StateString getInteractionState()
{
- return parameters;
+ return new ParametersStateString(parameters.getPrivateMapSnapshot());
}
/** The portlet container does not need to have the navigational state provided.
*/
@@ -182,20 +206,17 @@
}
}
- public static class InternalRenderURL extends InternalPortletURL implements RenderURL
+ protected class InternalRenderURL extends InternalPortletURL implements RenderURL
{
- /** . */
- private ParametersStateString navigationalState = new ParametersStateString();
-
- protected ParameterMap getInternalParameters()
+ private InternalRenderURL(PortletParameterMap parameters)
{
- return navigationalState.getParameters();
+ super(parameters);
}
public StateString getNavigationalState()
{
- return navigationalState;
+ return new ParametersStateString(parameters.getPrivateMapSnapshot());
}
}
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -122,12 +122,12 @@
public PortletURL createRenderURL()
{
- return PortletUtils.createRenderURL(invocation, preq);
+ return BaseURLImpl.createRenderURL(invocation, preq);
}
public PortletURL createActionURL()
{
- return PortletUtils.createActionURL(invocation, preq);
+ return BaseURLImpl.createActionURL(invocation, preq);
}
public String getCharacterEncoding()
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -27,7 +27,6 @@
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
-import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
@@ -39,9 +38,9 @@
public class PortletURLImpl extends BaseURLImpl implements PortletURL
{
- public PortletURLImpl(PortletInvocation invocation, PortletRequest preq,
InternalPortletURL url)
+ protected PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type
type)
{
- super(invocation, preq, url);
+ super(invocation, preq, type);
}
public void setWindowState(WindowState windowState) throws WindowStateException
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -22,13 +22,13 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.taglib;
-import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.impl.jsr168.api.BaseURLImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.PortletSecurityException;
import javax.portlet.PortletURL;
-import javax.portlet.RenderRequest;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
import javax.servlet.jsp.JspException;
@@ -186,16 +186,16 @@
*/
private PortletURL getBasePortletEnvironmentAndURL()
{
- RenderRequest preq = getRequest();
+ RenderRequestImpl preq = getRequest();
// Create the URL
if ("action".equals(getTypeValue()))
{
- return PortletUtils.createActionURL(getInvocation(), preq);
+ return BaseURLImpl.createActionURL(getInvocation(), preq);
}
else if ("render".equals(getTypeValue()))
{
- return PortletUtils.createRenderURL(getInvocation(), preq);
+ return BaseURLImpl.createRenderURL(getInvocation(), preq);
}
else
{
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java 2008-01-18
00:34:07 UTC (rev 9533)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/PortletTag.java 2008-01-18
09:58:02 UTC (rev 9534)
@@ -24,9 +24,9 @@
import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import javax.portlet.PortletConfig;
-import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
@@ -52,10 +52,10 @@
return invocation.getDispatchedRequest();
}
- protected RenderRequest getRequest()
+ protected RenderRequestImpl getRequest()
{
HttpServletRequest dreq = getDispatchedRequest();
- return (RenderRequest)dreq.getAttribute("javax.portlet.request");
+ return (RenderRequestImpl)dreq.getAttribute("javax.portlet.request");
}
protected RenderResponse getResponse()