Author: julien(a)jboss.com
Date: 2008-01-31 19:46:09 -0500 (Thu, 31 Jan 2008)
New Revision: 9693
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerListenerInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLGenerationListenerChain.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/PortletURLSnapshot.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener1.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener2.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.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/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
modules/portlet/trunk/test/src/test/build.xml
modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
Log:
- implemented PortletURLGenerationListener
- started to write test cases for PortletURLGenerationListener
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -38,6 +38,7 @@
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
+import org.jboss.portal.portlet.impl.metadata.ListenerMetaData;
import org.jboss.portal.portlet.impl.metadata.filter.FilterMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.LifeCyclePhase;
@@ -148,6 +149,10 @@
throw new Error(e);
}
}
+ if (tmp.getListeners() == null)
+ {
+ tmp.setListeners(new ArrayList<ListenerMetaData>());
+ }
}
}
@@ -266,6 +271,7 @@
//
String defaultNamespace = XMLConstants.NULL_NS_URI;
+ List<ContainerListenerInfo> listeners = Collections.emptyList();
if (this.portletApplicationMD instanceof PortletApplication20MetaData)
{
PortletApplication20MetaData tmp =
(PortletApplication20MetaData)this.portletApplicationMD;
@@ -297,6 +303,16 @@
}
//
+ listeners = new
ArrayList<ContainerListenerInfo>(tmp.getListeners().size());
+ for (ListenerMetaData listenerMD : tmp.getListeners())
+ {
+ ContainerListenerInfo listener = build(listenerMD);
+ listeners.add(listener);
+ }
+ listeners = Collections.unmodifiableList(listeners);
+
+
+ //
// for (FilterMetaData filterMD : tmp.getFilterCollection())
// {
// ContainerFilterInfo filter = build(filterMD);
@@ -304,9 +320,17 @@
}
//
- return new ContainerPortletApplicationInfo(defaultNamespace);
+ return new ContainerPortletApplicationInfo(defaultNamespace, listeners);
}
+ private ContainerListenerInfo build(ListenerMetaData listenerMD)
+ {
+ return new ContainerListenerInfo(
+ listenerMD.getListenerClass(),
+ listenerMD.getDisplayName(),
+ listenerMD.getDescription());
+ }
+
private ContainerFilterInfo build(FilterMetaData filterMD)
{
Map<String, String> initParameters = new HashMap<String, String>();
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerListenerInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerListenerInfo.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerListenerInfo.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.info;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerListenerInfo
+{
+
+ /** . */
+ private final String className;
+
+ /** . */
+ private final LocalizedString displayName;
+
+ /** . */
+ private final LocalizedString description;
+
+ public ContainerListenerInfo(String className, LocalizedString displayName,
LocalizedString description)
+ {
+ this.className = className;
+ this.displayName = displayName;
+ this.description = description;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletApplicationInfo.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.info;
+import java.util.List;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -32,13 +34,24 @@
/** . */
private final String defaultNamespace;
- public ContainerPortletApplicationInfo(String defaultNamespace)
+ /** . */
+ private final List<ContainerListenerInfo> listeners;
+
+ public ContainerPortletApplicationInfo(
+ String defaultNamespace,
+ List<ContainerListenerInfo> listeners)
{
this.defaultNamespace = defaultNamespace;
+ this.listeners = listeners;
}
public String getDefaultNamespace()
{
return defaultNamespace;
}
+
+ public List<ContainerListenerInfo> getListeners()
+ {
+ return listeners;
+ }
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -23,18 +23,26 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletURLGenerationListenerChain;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.metadata.PortletApplication10MetaData;
import org.jboss.portal.portlet.impl.info.ContainerPortletApplicationInfo;
+import org.jboss.portal.portlet.impl.info.ContainerListenerInfo;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletApplicationContext;
import org.jboss.portal.portlet.container.PortletContainer;
+import org.apache.log4j.Logger;
import javax.portlet.PortletContext;
+import javax.portlet.PortletURLGenerationListener;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+import java.lang.reflect.Constructor;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -43,6 +51,9 @@
public class PortletApplicationImpl implements PortletApplication
{
+ /** Logger. */
+ protected final Logger log;
+
/** . */
protected final ContainerPortletApplicationInfo info;
@@ -67,6 +78,9 @@
/** . */
protected String version;
+ /** . */
+ protected PortletURLGenerationListener urlListener;
+
/**
* Todo remove meta data reference and use info instead.
*
@@ -89,6 +103,7 @@
this.portletAPIFactory = portletAPIFactory;
this.portlets = new LinkedHashMap<String, PortletContainer>();
this.context = context;
+ this.log = Logger.getLogger("org.jboss.portal.portlet.application." +
context.getContextPath().replace('.', '_'));
}
public String getId()
@@ -130,14 +145,63 @@
public void start() throws Exception
{
- version = metaData.getVersion();
- portletContext = new PortletContextImpl(context.getServletContext());
+ List<PortletURLGenerationListener> listeners = Collections.emptyList();
+ for (ContainerListenerInfo listenerInfo : info.getListeners())
+ {
+ String className = listenerInfo.getClassName();
+ ClassLoader classLoader = context.getClassLoader();
+ try
+ {
+ Class clazz = classLoader.loadClass(className);
+ if (PortletURLGenerationListener.class.isAssignableFrom(clazz))
+ {
+ Constructor ctor = clazz.getConstructor();
+ PortletURLGenerationListener listener =
(PortletURLGenerationListener)ctor.newInstance();
+ if (listeners.size() == 0)
+ {
+ listeners = new LinkedList<PortletURLGenerationListener>();
+ }
+ listeners.add(listener);
+ }
+ else
+ {
+ log.info("Cannot create filter with class " + className + "
because it does not implement the PortletURLGenerationListener interface");
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Cannot create filter with class " + className + "
because the class is not accessible", e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.error("Cannot create filter with class " + className + "
because it does not have an no argument constructor", e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Cannot create filter with class " + className + "
because the class cannot be loaded", e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error("Cannot create filter with class " + className + "
because it cannot be instantiated", e);
+ }
+ catch (Error e)
+ {
+ log.error("Cannot create filter with class " + className + "
because of an error", e);
+ }
+ }
+
+ //
+ this.version = metaData.getVersion();
+ this.portletContext = new PortletContextImpl(context.getServletContext());
+ this.urlListener = listeners.size() == 0 ? null : new
PortletURLGenerationListenerChain(Collections.unmodifiableList(listeners));
+
}
public void stop()
{
- version = null;
- portletContext = null;
+ this.version = null;
+ this.portletContext = null;
+ this.urlListener = null;
}
public String getVersion()
@@ -150,6 +214,17 @@
return portletContext;
}
+ public <T> T getListener(Class<T> type)
+ {
+ if (type == PortletURLGenerationListener.class)
+ {
+ return type.cast(urlListener);
+ }
+
+ //
+ return null;
+ }
+
// WebApp implementation
********************************************************************************************
public Set<PortletContainer> getPortletContainers()
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameter.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -31,16 +31,14 @@
enum Scope
{
-
PUBLIC, PRIVATE
-
}
/** The entry scope. */
private final Scope scope;
/** The entry value. */
- private String[] values;
+ private final String[] values;
PortletParameter(Scope scope, String[] values)
{
@@ -57,9 +55,4 @@
{
return values;
}
-
- void setValues(String[] values)
- {
- this.values = values;
- }
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletParameterMap.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -58,6 +58,13 @@
this.navigationInfo = navigationInfo;
}
+ public PortletParameterMap(PortletParameterMap original)
+ {
+ this.navigationInfo = original.navigationInfo;
+ this.entries = new HashMap<String, PortletParameter>(original.entries);
+ this.publicEntryRemovals = new HashSet<String>(publicEntryRemovals);
+ }
+
public String getParameterValue(String name)
{
String[] values = getParameterValues(name);
@@ -122,36 +129,34 @@
private void internalPut(String name, String[] value, boolean cloneValue)
{
+ if (cloneValue)
+ {
+ value = value.clone();
+ }
+
// Look if we have an entry already
PortletParameter entry = entries.get(name);
//
- PortletParameter.Scope scope;
if (entry == null)
{
ParameterInfo parameterInfo = navigationInfo.getPublicParameter(name);
- scope = parameterInfo == null ? PortletParameter.Scope.PRIVATE :
PortletParameter.Scope.PUBLIC;
- }
- else
- {
- scope = entry.getScope();
- }
- //
- if (cloneValue)
- {
- value = value.clone();
- }
+ //
+ PortletParameter.Scope scope = parameterInfo == null ?
PortletParameter.Scope.PRIVATE : PortletParameter.Scope.PUBLIC;
- //
- if (entry == null)
- {
- publicEntryRemovals.remove(name);
+ //
+ if (scope == PortletParameter.Scope.PUBLIC)
+ {
+ publicEntryRemovals.remove(name);
+ }
+
+ //
entries.put(name, new PortletParameter(scope, value));
}
else
{
- entry.setValues(value);
+ entries.put(name, new PortletParameter(entry.getScope(), value));
}
}
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-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -24,11 +24,12 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.BaseURL;
import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURLGenerationListener;
import java.util.Map;
import java.io.Writer;
import java.io.IOException;
@@ -47,31 +48,44 @@
protected final PortletRequestImpl preq;
/** . */
- protected final InternalContainerURL url;
+ protected Boolean secure;
/** . */
- protected Boolean secure;
+ protected final boolean filterable;
- protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq,
InternalContainerURL url)
+ protected BaseURLImpl(
+ PortletInvocation invocation,
+ PortletRequestImpl preq,
+ boolean filterable)
{
this.inv = invocation;
this.preq = preq;
- this.url = url;
+ this.filterable = filterable;
}
+ protected BaseURLImpl(BaseURLImpl original)
+ {
+ this.inv = original.inv;
+ this.preq = original.preq;
+ this.filterable = false;
+ }
+
/** @throws IllegalArgumentException if the name is null */
public void setParameter(String name, String value)
{
+ InternalContainerURL url = getContainerURL();
url.setParameter(name, value);
}
public void setParameter(String name, String[] values)
{
+ InternalContainerURL url = getContainerURL();
url.setParameter(name, values);
}
public void setParameters(Map<String, String[]> parameters)
{
+ InternalContainerURL url = getContainerURL();
url.setParameters(parameters);
}
@@ -82,7 +96,8 @@
public Map<String, String[]> getParameterMap()
{
- throw new NotYetImplemented();
+ InternalContainerURL url = getContainerURL();
+ return url.getParameters();
}
public void write(Writer writer) throws IOException
@@ -107,10 +122,33 @@
public String toString()
{
+ PortletURLGenerationListener listener =
((PortletApplicationImpl)preq.container.getApplication()).getListener(PortletURLGenerationListener.class);
+
+ //
+ InternalContainerURL url;
+ if (listener != null)
+ {
+ // Create a safe clone
+ BaseURLImpl clone = createClone();
+ clone.filter(listener);
+ url = clone.getContainerURL();
+ }
+ else
+ {
+ url = getContainerURL();
+ }
+
+ //
PortletInvocationContext responseContext = inv.getContext();
return responseContext.renderURL(url, secure, null, true);
}
+ protected abstract void filter(PortletURLGenerationListener listener);
+
+ protected abstract BaseURLImpl createClone();
+
+ protected abstract InternalContainerURL getContainerURL();
+
protected static abstract class InternalContainerURL implements
org.jboss.portal.portlet.ContainerURL
{
@@ -120,5 +158,8 @@
protected abstract void setParameters(Map<String, String[]> parameters);
+ protected abstract Map<String, String[]> getParameters();
+
}
+
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLGenerationListenerChain.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLGenerationListenerChain.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLGenerationListenerChain.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import java.util.List;
+
+/**
+ * An implementation of the API that chains.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletURLGenerationListenerChain implements PortletURLGenerationListener
+{
+
+ /** . */
+ private PortletURLGenerationListener[] listeners;
+
+ public PortletURLGenerationListenerChain(List<PortletURLGenerationListener>
listeners)
+ {
+ this.listeners = listeners.toArray(new
PortletURLGenerationListener[listeners.size()]);
+ }
+
+ public void filterActionURL(PortletURL portletURL)
+ {
+ for (PortletURLGenerationListener listener : listeners)
+ {
+ try
+ {
+ listener.filterActionURL(portletURL);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void filterRenderURL(PortletURL portletURL)
+ {
+ for (PortletURLGenerationListener listener : listeners)
+ {
+ try
+ {
+ listener.filterRenderURL(portletURL);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void filterResourceURL(ResourceURL resourceURL)
+ {
+ for (PortletURLGenerationListener listener : listeners)
+ {
+ try
+ {
+ listener.filterResourceURL(resourceURL);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
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-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
import org.jboss.portal.portlet.ActionURL;
@@ -36,6 +37,7 @@
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
+import javax.portlet.PortletURLGenerationListener;
import java.util.Map;
/**
@@ -48,26 +50,38 @@
public static PortletURLImpl createActionURL(PortletInvocation invocation,
PortletRequestImpl preq)
{
InternalActionURL url = new InternalActionURL();
- return new PortletURLImpl(invocation, preq, url);
+ return new PortletURLImpl(invocation, preq, url, true);
}
public static PortletURLImpl createRenderURL(PortletInvocation invocation,
PortletRequestImpl preq)
{
InternalRenderURL url = new InternalRenderURL(new
PortletParameterMap(preq.navigationInfo));
- return new PortletURLImpl(invocation, preq, url);
+ return new PortletURLImpl(invocation, preq, url, true);
}
/** . */
private final InternalPortletURL url;
- private PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq,
InternalPortletURL url)
+ private PortletURLImpl(
+ PortletInvocation invocation,
+ PortletRequestImpl preq,
+ InternalPortletURL url,
+ boolean filterable)
{
- super(invocation, preq, url);
+ super(invocation, preq, filterable);
//
this.url = url;
}
+ public PortletURLImpl(PortletURLImpl original)
+ {
+ super(original);
+
+ //
+ this.url = original.url instanceof InternalRenderURL ? new
InternalRenderURL((InternalRenderURL)original.url) : new
InternalActionURL((InternalActionURL)original.url);
+ }
+
public void setWindowState(WindowState windowState) throws WindowStateException
{
if (!preq.isWindowStateAllowed(windowState))
@@ -100,12 +114,12 @@
public PortletMode getPortletMode()
{
- throw new NotYetImplemented();
+ return url.portletMode;
}
public WindowState getWindowState()
{
- throw new NotYetImplemented();
+ return url.windowState;
}
public void removePublicRenderParameter(String name)
@@ -113,6 +127,28 @@
url.removePublicRenderParameter(name);
}
+ protected InternalContainerURL getContainerURL()
+ {
+ return url;
+ }
+
+ protected BaseURLImpl createClone()
+ {
+ return new PortletURLImpl(this);
+ }
+
+ protected void filter(PortletURLGenerationListener listener)
+ {
+ if (url instanceof InternalActionURL)
+ {
+ listener.filterActionURL(this);
+ }
+ else
+ {
+ listener.filterRenderURL(this);
+ }
+ }
+
private static abstract class InternalPortletURL extends InternalContainerURL
implements org.jboss.portal.portlet.PortletURL
{
@@ -122,6 +158,18 @@
/** . */
protected PortletMode portletMode;
+ protected InternalPortletURL()
+ {
+ this.windowState = null;
+ this.portletMode = null;
+ }
+
+ protected InternalPortletURL(InternalPortletURL original)
+ {
+ this.windowState = original.windowState;
+ this.portletMode = original.portletMode;
+ }
+
public Mode getMode()
{
if (portletMode != null)
@@ -154,6 +202,14 @@
this.interactionState = ParametersStateString.create();
}
+ private InternalActionURL(InternalActionURL original)
+ {
+ super(original);
+
+ //
+ this.interactionState =
ParametersStateString.create(ParameterMap.clone(original.interactionState.getParameters()));
+ }
+
public StateString getInteractionState()
{
return interactionState;
@@ -177,6 +233,11 @@
protected void removePublicRenderParameter(String name)
{
}
+
+ protected Map<String, String[]> getParameters()
+ {
+ return ParameterMap.clone(interactionState.getParameters());
+ }
}
private static class InternalRenderURL extends InternalPortletURL implements
RenderURL
@@ -189,6 +250,14 @@
this.parameters = parameters;
}
+ private InternalRenderURL(InternalRenderURL original)
+ {
+ super(original);
+
+ //
+ this.parameters = new PortletParameterMap(original.parameters);
+ }
+
public StateString getNavigationalState()
{
return ParametersStateString.create(parameters.getPrivateMapSnapshot());
@@ -218,5 +287,10 @@
{
parameters.removePublicParameterValue(name);
}
+
+ protected Map<String, String[]> getParameters()
+ {
+ return ParameterMap.clone(parameters.getMap());
+ }
}
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -27,8 +27,10 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.common.util.ParameterMap;
import javax.portlet.ResourceURL;
+import javax.portlet.PortletURLGenerationListener;
import java.util.Map;
import java.util.HashMap;
@@ -68,9 +70,10 @@
private ResourceURLImpl(
PortletInvocation invocation,
PortletRequestImpl preq,
- InternalResourceURL url)
+ InternalResourceURL url,
+ boolean filterable)
{
- super(invocation, preq, url);
+ super(invocation, preq, filterable);
//
this.url = url;
@@ -82,6 +85,14 @@
}
}
+ private ResourceURLImpl(ResourceURLImpl original)
+ {
+ super(original);
+
+ //
+ this.url = new InternalResourceURL(original.url);
+ }
+
public void setResourceID(String resourceID)
{
if (resourceID != null)
@@ -131,9 +142,24 @@
}
}
+ protected InternalContainerURL getContainerURL()
+ {
+ return url;
+ }
+
+ protected BaseURLImpl createClone()
+ {
+ return new ResourceURLImpl(this);
+ }
+
+ protected void filter(PortletURLGenerationListener listener)
+ {
+ listener.filterResourceURL(this);
+ }
+
public static ResourceURLImpl createResourceURL(PortletInvocation invocation,
PortletRequestImpl preq)
{
- return new ResourceURLImpl(invocation, preq, new InternalResourceURL());
+ return new ResourceURLImpl(invocation, preq, new InternalResourceURL(), true);
}
private static class InternalResourceURL extends InternalContainerURL implements
org.jboss.portal.portlet.ResourceURL
@@ -156,6 +182,14 @@
this.parameters = ParametersStateString.create();
}
+ private InternalResourceURL(InternalResourceURL original)
+ {
+ this.id = original.id;
+ this.parentCacheLevel = original.parentCacheLevel;
+ this.cacheLevel = original.cacheLevel;
+ this.parameters =
ParametersStateString.create(ParameterMap.clone(original.parameters.getParameters()));
+ }
+
protected void setParameter(String name, String value)
{
parameters.setValue(name, value);
@@ -171,6 +205,11 @@
parameters.replace(parameterMap);
}
+ protected Map<String, String[]> getParameters()
+ {
+ return ParameterMap.clone(parameters.getParameters());
+ }
+
public StateString getResourceState()
{
return parameters;
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/PortletURLSnapshot.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/PortletURLSnapshot.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/PortletURLSnapshot.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import org.jboss.unit.api.Assert;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import java.util.Map;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletURLSnapshot
+{
+
+ /** . */
+ public static LinkedList<PortletURLSnapshot> queue = new
LinkedList<PortletURLSnapshot>();
+
+ public static PortletURLSnapshot next()
+ {
+ Assert.assertTrue(queue.size() > 0);
+ return queue.removeFirst();
+ }
+
+ public static int size()
+ {
+ return queue.size();
+ }
+
+ /** . */
+ private static final int ACTION = 0;
+
+ /** . */
+ private static final int RENDER = 1;
+
+ /** . */
+ private static final int RESOURCE = 2;
+
+ /** . */
+ final Class source;
+
+ /** . */
+ final int type;
+
+ /** . */
+ final PortletMode portletMode;
+
+ /** . */
+ final WindowState windowState;
+
+ /** . */
+ final Map<String, String[]> parameters;
+
+ public static PortletURLSnapshot createActionURL(Class source, PortletURL actionURL)
+ {
+ return new PortletURLSnapshot(source, ACTION, actionURL);
+ }
+
+ public static PortletURLSnapshot createRenderURL(Class source, PortletURL renderURL)
+ {
+ return new PortletURLSnapshot(source, RENDER, renderURL);
+ }
+
+ public static PortletURLSnapshot createResourceURL(Class source, ResourceURL
resourceURL)
+ {
+ return new PortletURLSnapshot(source, resourceURL);
+ }
+
+ public static PortletURLSnapshot createActionURL(Class source, PortletMode
portletMode, WindowState windowState, Map<String, String[]> parameters)
+ {
+ return new PortletURLSnapshot(source, ACTION, portletMode, windowState,
parameters);
+ }
+
+ public static PortletURLSnapshot createRenderRL(Class source, PortletMode portletMode,
WindowState windowState, Map<String, String[]> parameters)
+ {
+ return new PortletURLSnapshot(source, RENDER, portletMode, windowState,
parameters);
+ }
+
+ public static PortletURLSnapshot createResourceURL(Class source, Map<String,
String[]> parameters)
+ {
+ return new PortletURLSnapshot(source, parameters);
+ }
+
+ private PortletURLSnapshot(Class source, int type, PortletURL portletURL)
+ {
+ this.source = source;
+ this.type = type;
+ this.portletMode = portletURL.getPortletMode();
+ this.windowState = portletURL.getWindowState();
+ this.parameters = portletURL.getParameterMap();
+ }
+
+ private PortletURLSnapshot(Class source, ResourceURL portletURL)
+ {
+ this.source = source;
+ this.type = RESOURCE;
+ this.portletMode = null;
+ this.windowState = null;
+ this.parameters = portletURL.getParameterMap();
+ }
+
+ private PortletURLSnapshot(Class source, int type, PortletMode portletMode,
WindowState windowState, Map<String, String[]> parameters)
+ {
+ this.source = source;
+ this.type = type;
+ this.portletMode = portletMode;
+ this.windowState = windowState;
+ this.parameters = parameters;
+ }
+
+ private PortletURLSnapshot(Class source, Map<String, String[]> parameters)
+ {
+ this.source = source;
+ this.type = RESOURCE;
+ this.portletMode = null;
+ this.windowState = null;
+ this.parameters = parameters;
+ }
+
+ public void assertEquals(PortletURLSnapshot actual)
+ {
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(source, actual.source);
+ Assert.assertEquals(type, actual.type);
+ Assert.assertEquals(parameters.keySet(), actual.parameters.keySet());
+ for (Map.Entry<String, String[]> entry : parameters.entrySet())
+ {
+ Assert.assertEquals(entry.getValue(), actual.parameters.get(entry.getKey()));
+ }
+ if (type == RESOURCE)
+ {
+
+ }
+ else
+ {
+ Assert.assertEquals(portletMode, actual.portletMode);
+ Assert.assertEquals(windowState, actual.windowState);
+ }
+ }
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class URLGenerationListener implements PortletURLGenerationListener
+{
+
+ public void filterActionURL(PortletURL portletURL)
+ {
+ PortletURLSnapshot.queue.addLast(PortletURLSnapshot.createActionURL(getClass(),
portletURL));
+ }
+
+ public void filterRenderURL(PortletURL portletURL)
+ {
+ PortletURLSnapshot.queue.addLast(PortletURLSnapshot.createRenderURL(getClass(),
portletURL));
+ }
+
+ public void filterResourceURL(ResourceURL resourceURL)
+ {
+ PortletURLSnapshot.queue.addLast(PortletURLSnapshot.createResourceURL(getClass(),
resourceURL));
+ }
+}
\ No newline at end of file
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener1.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener1.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener1.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class URLGenerationListener1 extends URLGenerationListener
+{
+}
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener2.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener2.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListener2.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class URLGenerationListener2 extends URLGenerationListener
+{
+}
\ No newline at end of file
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portleturl/URLGenerationListenerTestCase.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr286.tck.portleturl;
+
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.test.portlet.framework.UTP1;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletMode;
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@TestCase
+public class URLGenerationListenerTestCase
+{
+ public URLGenerationListenerTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ PortletURL actionURL = response.createActionURL();
+
+ //
+ actionURL.toString();
+ PortletURLSnapshot actionSnapshot1 = PortletURLSnapshot.next();
+ PortletURLSnapshot actionSnapshot2 = PortletURLSnapshot.next();
+ assertEquals(0, PortletURLSnapshot.size());
+
actionSnapshot1.assertEquals(PortletURLSnapshot.createActionURL(URLGenerationListener1.class,
null, null, new HashMap<String, String[]>()));
+
actionSnapshot2.assertEquals(PortletURLSnapshot.createActionURL(URLGenerationListener2.class,
null, null, new HashMap<String, String[]>()));
+
+ //
+ actionURL.setPortletMode(PortletMode.EDIT);
+ actionURL.toString();
+ actionSnapshot1 = PortletURLSnapshot.next();
+ actionSnapshot2 = PortletURLSnapshot.next();
+ assertEquals(0, PortletURLSnapshot.size());
+
actionSnapshot1.assertEquals(PortletURLSnapshot.createActionURL(URLGenerationListener1.class,
PortletMode.EDIT, null, new HashMap<String, String[]>()));
+
actionSnapshot2.assertEquals(PortletURLSnapshot.createActionURL(URLGenerationListener2.class,
PortletMode.EDIT, null, new HashMap<String, String[]>()));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-01
00:44:39 UTC (rev 9692)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletApplicationDeployment.java 2008-02-01
00:46:09 UTC (rev 9693)
@@ -299,6 +299,6 @@
public String getContextPath()
{
- throw new NotYetImplemented();
+ return webApp.getContextPath();
}
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-01 00:44:39 UTC (rev 9692)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-01 00:46:09 UTC (rev 9693)
@@ -350,6 +350,7 @@
<package-jsr286-tck-test test="stateawareresponse"/>
<package-jsr286-tck-test test="portletrequests"/>
<package-jsr286-tck-test test="resourceserving"/>
+ <package-jsr286-tck-test test="portleturl"/>
<package-jsr286-api-test test="event"/>
Added:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/portlet.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/portlet.xml 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+
+ <portlet>
+ <portlet-name>UniversalTestPortletA</portlet-name>
+
<portlet-class>org.jboss.portal.test.portlet.framework.UTP1</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>EDIT</portlet-mode>
+ </supports>
+
<supported-public-render-parameter>foo</supported-public-render-parameter>
+ </portlet>
+
+ <listener>
+
<listener-class>org.jboss.portal.test.portlet.jsr286.tck.portleturl.URLGenerationListener1</listener-class>
+ </listener>
+ <listener>
+
<listener-class>org.jboss.portal.test.portlet.jsr286.tck.portleturl.URLGenerationListener2</listener-class>
+ </listener>
+
+</portlet-app>
Added:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/web.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/web.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portleturl-war/WEB-INF/web.xml 2008-02-01
00:46:09 UTC (rev 9693)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <listener>
+
<listener-class>org.jboss.portal.unit.PortletTestSuite</listener-class>
+ </listener>
+</web-app>
Modified: modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-01
00:44:39 UTC (rev 9692)
+++ modules/portlet/trunk/test/src/test/resources/test/remote-jboss-unit.xml 2008-02-01
00:46:09 UTC (rev 9693)
@@ -179,6 +179,10 @@
<class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
<property name="archiveId"
value="test-jsr286-tck-resourceserving.war"/>
</generic>
+ <generic>
+ <class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ <property name="archiveId"
value="test-jsr286-tck-portleturl.war"/>
+ </generic>
<!--Spec API Assertions tests-->
<generic>