Author: julien(a)jboss.com
Date: 2008-01-14 06:10:14 -0500 (Mon, 14 Jan 2008)
New Revision: 9498
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
Log:
- early implementation of consumer side event delivery by the portal test
- basic test case for eventing
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ProducerCacheInterceptor.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -29,6 +29,7 @@
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
@@ -52,6 +53,11 @@
// Invoke
return invocation.invokeNext();
}
+ else if (invocation instanceof EventInvocation)
+ {
+ // Invoke
+ return invocation.invokeNext();
+ }
else if (invocation instanceof RenderInvocation)
{
// Invoke
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -355,6 +355,10 @@
{
return invokeRender((RenderInvocation)invocation);
}
+ else if (invocation instanceof EventInvocation)
+ {
+ return invokeEvent((EventInvocation)invocation);
+ }
else
{
throw new InvocationException("Unexpected invocation " +
invocation);
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -24,6 +24,9 @@
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
import javax.portlet.EventRequest;
import javax.portlet.Event;
@@ -41,6 +44,27 @@
public EventRequestImpl(EventInvocation invocation)
{
super(invocation);
+
+ //
+ PortletInvocationContext context = invocation.getPortletContext();
+
+ // Get the possibly null navigational state
+ StateString navigationalState = context.getNavigationalState();
+
+ //
+ if (navigationalState == null)
+ {
+
+ }
+ else if (navigationalState instanceof PortletParametersStateString)
+ {
+ parameters = ((PortletParametersStateString)navigationalState).getParameters();
+ }
+ else
+ {
+ PortletParametersStateString parametersState = new
PortletParametersStateString(navigationalState.getStringValue());
+ parameters = parametersState.getParameters();
+ }
}
public Event getEvent()
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -26,6 +26,7 @@
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.RenderRequest;
@@ -40,18 +41,15 @@
public class RenderRequestImpl extends PortletRequestImpl implements RenderRequest
{
- /** . */
- protected RenderContext renderContext;
-
public RenderRequestImpl(RenderInvocation invocation)
{
super(invocation);
// Get the render context
- renderContext = (RenderContext)invocation.getPortletContext();
+ PortletInvocationContext context = invocation.getPortletContext();
// Get the possibly null navigational state
- StateString navigationalState = renderContext.getNavigationalState();
+ StateString navigationalState = context.getNavigationalState();
//
if (navigationalState == null)
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractEventContext.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.spi;
+
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractEventContext extends AbstractPortletInvocationContext
implements EventContext
+{
+
+ /** . */
+ protected QName name;
+
+ /** . */
+ protected Serializable payload;
+
+ protected AbstractEventContext(
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ MarkupInfo markupInfo,
+ QName name,
+ Serializable payload)
+ {
+ super(mode, windowState, navigationalState, markupInfo);
+
+ //
+ this.name = name;
+ this.payload = payload;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public Serializable getPayload()
+ {
+ return payload;
+ }
+}
\ No newline at end of file
Deleted:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/RenderResponse.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -1,85 +0,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. *
- ******************************************************************************/
-package org.jboss.portal.portlet.invocation.response;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.portlet.StateString;
-
-/**
- * Want to be rendered.
- *
- * @todo rename to UpdateNavigationalStateResponse
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5477 $
- */
-public class RenderResponse extends StateResponse
-{
-
- /** The navigational state returned. */
- protected StateString state;
-
- /** The new window state requested. */
- protected WindowState windowState;
-
- /** The new mode requested. */
- protected Mode mode;
-
- public RenderResponse()
- {
- state = null;
- windowState = null;
- mode = null;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public void setMode(Mode mode)
- {
- this.mode = mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public void setWindowState(WindowState windowState)
- {
- this.windowState = windowState;
- }
-
- public StateString getNavigationalState()
- {
- return state;
- }
-
- public void setNavigationalState(StateString state)
- {
- this.state = state;
- }
-}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventTestCase.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -33,6 +33,7 @@
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 org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
import javax.portlet.RenderRequest;
@@ -66,18 +67,24 @@
protected void run(Portlet portlet, ActionRequest request, ActionResponse
response, PortletTestContext context) throws PortletException, IOException
{
response.setEvent("Foo", null);
+ response.setRenderParameter("bar", "bar");
}
});
seq.bindAction(1, UTP1.EVENT_JOIN_POINT, new PortletEventTestAction()
{
protected void run(Portlet portlet, EventRequest request, EventResponse
response, PortletTestContext context) throws PortletException, IOException
{
+ String bar = request.getParameter("bar");
+ assertEquals("bar", bar);
+ response.setRenderParameter("bar", "juu");
}
});
seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request,
RenderResponse response, PortletTestContext context)
{
+ String bar = request.getParameter("bar");
+ assertEquals("juu", bar);
return new EndTestResponse();
}
});
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalNavigationalState.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -41,11 +41,11 @@
{
/** . */
- private final Map windows = new HashMap();
+ private final Map<String, WindowNavigationalState> windows = new
HashMap<String, WindowNavigationalState>();
public WindowNavigationalState getWindow(String windowId)
{
- return (WindowNavigationalState)windows.get(windowId);
+ return windows.get(windowId);
}
public void setWindow(String windowId, WindowNavigationalState window)
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.EventInfo;
import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
@@ -39,12 +41,14 @@
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -52,6 +56,9 @@
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -66,8 +73,12 @@
/** . */
private final boolean redirectAfterAction = true;
+ /** . */
+ private final Logger log;
+
public PortletController() throws IllegalRequestException,
UnsupportedEncodingException
{
+ log = Logger.getLogger(PortletController.class);
}
private PortletInvocationResponse handle(PortletControllerContext context, Action
action) throws PortletInvokerException, IOException
@@ -151,6 +162,55 @@
}
}
+ private PortletInvocationResponse deliverEvent(
+ PortletControllerContext context,
+ Portlet portlet,
+ StateResponse.Event event)
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState navState = context.getNavigationalState();
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
+ WindowNavigationalState windowNS =
navState.getWindow(portlet.getContext().getId());
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
+ TestEventContext actionContext = new TestEventContext(
+ renderer,
+ windowNS.getMode(),
+ windowNS.getWindowState(),
+ windowNS.getPortletNavigationalState(),
+ MARKUP_INFO,
+ event.getName(),
+ event.getPayload());
+ EventInvocation eventInvocation = new EventInvocation(actionContext);
+
+ //
+ eventInvocation.setRequestContext(new AbstractRequestContext(req, resp));
+ eventInvocation.setInstanceContext(instanceContext);
+ eventInvocation.setUserContext(new AbstractUserContext(req));
+ eventInvocation.setWindowContext(new
AbstractWindowContext(portlet.getContext().getId()));
+ eventInvocation.setPortalContext(new AbstractPortalContext());
+ eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ eventInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(eventInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
+ }
+
public void process(PortletControllerContext context, Action action) throws
PortletInvokerException, IOException
{
HttpServletRequest req = context.getClientRequest();
@@ -163,17 +223,113 @@
PortletInvocationResponse response = handle(context, action);
//
- if (response instanceof StateResponse)
+ if (response instanceof ErrorResponse)
{
+ ErrorResponse error = (ErrorResponse)response;
+
+ //
+ if (error.getCause() != null)
+ {
+ log.error("Portlet action threw an error: " +
error.getMessage(), error.getCause());
+ }
+ else
+ {
+ log.error("Portlet action threw an error: " +
error.getMessage());
+ }
+
+ //
+ resp.sendError(404, error.getMessage());
+ }
+ else if (response instanceof StateResponse)
+ {
StateResponse stateResponse = (StateResponse)response;
+ // Update portlet NS
+ if (response instanceof UpdateNavigationalStateResponse)
+ {
+ updateNavigationalState(navState, action.portletId,
(UpdateNavigationalStateResponse)response);
+ }
+
+ // Create event list and feed it with the events that may have been produced
+ LinkedList<StateResponse.Event> queue = new
LinkedList<StateResponse.Event>();
+ queue.addAll(stateResponse.getEvents());
+
//
- for (StateResponse.Event event : stateResponse.getEvents())
+ while (queue.size() > 0)
{
-
+ StateResponse.Event event = queue.removeFirst();
+
+ //
+ List<Portlet> consumers = new ArrayList<Portlet>();
+ for (Portlet portlet : context.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+
+ //
+ for (EventInfo eventInfo :
portletInfo.getEvents().getConsumedEvents())
+ {
+ if (event.getName().equals(eventInfo.getName()))
+ {
+ consumers.add(portlet);
+ }
+ }
+ }
+
+ //
+ for (Portlet consumer : consumers)
+ {
+ PortletInvocationResponse eventResponse = deliverEvent(context,
consumer, event);
+
+ //
+ if (eventResponse instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse update =
(UpdateNavigationalStateResponse)eventResponse;
+
+ // Update ns
+ updateNavigationalState(navState, consumer.getContext().getId(),
update);
+
+ // Add events if any
+ queue.addAll(update.getEvents());
+ }
+ else if (eventResponse instanceof ErrorResponse)
+ {
+ // Do something here !!!!
+ }
+ else
+ {
+ // Do something here !!!!
+ }
+ }
}
+
+ //
+ if (response instanceof HTTPRedirectionResponse)
+ {
+ HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
+ resp.sendRedirect(redirection.getLocation());
+ return;
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ System.out.println("Error " + error.getMessage());
+ if (error.getCause() != null)
+ {
+ error.getCause().printStackTrace();
+ }
+ resp.sendError(404, error.getMessage());
+ return;
+ }
}
+ else
+ {
+ System.out.println("Not yet handled " + response);
+ }
+
+
+
+
/*
if (response instanceof RenderResponse && redirectAfterAction)
{
@@ -197,55 +353,6 @@
response = new HTTPRedirectionResponse(location);
}
*/
-
- //
- if (response instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse updateNavigationalState =
(UpdateNavigationalStateResponse)response;
- WindowNavigationalState windowNS = navState.getWindow(action.portletId);
-
- //
- if (windowNS == null)
- {
- windowNS = new WindowNavigationalState();
- navState.setWindow(action.portletId, windowNS);
- }
-
- //
- if (updateNavigationalState.getMode() != null)
- {
- windowNS.setMode(updateNavigationalState.getMode());
- }
- if (updateNavigationalState.getWindowState() != null)
- {
- windowNS.setWindowState(updateNavigationalState.getWindowState());
- }
- if (updateNavigationalState.getNavigationalState() != null)
- {
-
windowNS.setPortletNavigationalState(updateNavigationalState.getNavigationalState());
- }
- }
- else if (response instanceof HTTPRedirectionResponse)
- {
- HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
- resp.sendRedirect(redirection.getLocation());
- return;
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- System.out.println("Error " + error.getMessage());
- if (error.getCause() != null)
- {
- error.getCause().printStackTrace();
- }
- resp.sendError(404, error.getMessage());
- return;
- }
- else
- {
- System.out.println("Not yet handled " + response);
- }
}
//
@@ -321,6 +428,39 @@
writer.print("</body></html>");
}
+ private void updateNavigationalState(
+ PortalNavigationalState portalNS,
+ String windowId,
+ UpdateNavigationalStateResponse update)
+ {
+ WindowNavigationalState windowNS = portalNS.getWindow(windowId);
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
+ //
+ Mode mode = windowNS.getMode();
+ if (update.getMode() != null)
+ {
+ mode = update.getMode();
+ }
+ WindowState windowState = windowNS.getWindowState();
+ if (update.getWindowState() != null)
+ {
+ windowState = update.getWindowState();
+ }
+ StateString portletNS = windowNS.getPortletNavigationalState();
+ if (update.getNavigationalState() != null)
+ {
+ portletNS = update.getNavigationalState();
+ }
+ windowNS = new WindowNavigationalState(portletNS, mode, windowState);
+ portalNS.setWindow(windowId, windowNS);
+ }
+
static class Action
{
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.impl.spi.AbstractEventContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestEventContext extends AbstractEventContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public TestEventContext(
+ PortletURLRenderer urlRenderer,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ MarkupInfo markupInfo,
+ QName name,
+ Serializable payload)
+ {
+ super(mode, windowState, navigationalState, markupInfo, name, payload);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/WindowNavigationalState.java 2008-01-14
11:10:14 UTC (rev 9498)
@@ -36,41 +36,40 @@
{
/** . */
- private StateString portletNavigationalState;
+ private final StateString portletNavigationalState;
/** . */
- private Mode mode;
+ private final Mode mode;
/** . */
- private WindowState windowState;
+ private final WindowState windowState;
- public StateString getPortletNavigationalState()
+ public WindowNavigationalState()
{
- return portletNavigationalState;
+ this.portletNavigationalState = null;
+ this.mode = Mode.VIEW;
+ this.windowState = WindowState.NORMAL;
}
- public void setPortletNavigationalState(StateString portletNavigationalState)
+ public WindowNavigationalState(StateString portletNavigationalState, Mode mode,
WindowState windowState)
{
this.portletNavigationalState = portletNavigationalState;
+ this.mode = mode;
+ this.windowState = windowState;
}
- public Mode getMode()
+ public StateString getPortletNavigationalState()
{
- return mode;
+ return portletNavigationalState;
}
- public void setMode(Mode mode)
+ public Mode getMode()
{
- this.mode = mode;
+ return mode;
}
public WindowState getWindowState()
{
return windowState;
}
-
- public void setWindowState(WindowState windowState)
- {
- this.windowState = windowState;
- }
}
Modified:
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-14
10:16:55 UTC (rev 9497)
+++
modules/portlet/trunk/test/src/test/resources/jsr286/tck/event-war/WEB-INF/portlet.xml 2008-01-14
11:10:14 UTC (rev 9498)
@@ -33,6 +33,16 @@
<supports>
<mime-type>text/html</mime-type>
</supports>
+ <supported-processing-event>
+ <name>Foo</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Foo</name>
+ </supported-publishing-event>
</portlet>
+ <event-definition>
+ <name>Foo</name>
+ </event-definition>
+
</portlet-app>