JBoss Portal SVN: r9690 - in modules/portlet/trunk/test/src/main/java/org/jboss/portal: portlet/test/controller and 1 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-01-31 18:58:12 -0500 (Thu, 31 Jan 2008)
New Revision: 9690
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
Removed:
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/PortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
Log:
- Move PortletController and PortletControllerContext* to controller package.
- PortletController.process now delegates to RequestHandlers.
- Next step is cleaning up client interface.
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-31 23:10:24 UTC (rev 9689)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -22,10 +22,13 @@
******************************************************************************/
package org.jboss.portal.portlet.test;
+import org.jboss.portal.portlet.test.controller.PortletController;
+import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
+
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
import java.io.IOException;
/**
Deleted: 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-31 23:10:24 UTC (rev 9689)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -1,1056 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, 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.apache.log4j.Logger;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.common.util.MultiValuedPropertyMap;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.test.event.EventControllerContext;
-import org.jboss.portal.portlet.test.event.Event;
-import org.jboss.portal.portlet.cache.CacheLevel;
-import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
-import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
-import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.info.NavigationInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.EventInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.ResourceInvocation;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ResponseProperties;
-import org.jboss.portal.portlet.invocation.response.StateResponse;
-import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.portlet.spi.ResourceInvocationContext;
-import org.jboss.portal.web.IllegalRequestException;
-import org.w3c.dom.Element;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletController
-{
-
- /** . */
- private MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
-
- /** . */
- // private final boolean redirectAfterAction = true;
-
- /** . */
- private final Logger log;
-
- /** . */
- private final PortalContext portalContext;
-
- public PortletController() throws IllegalRequestException, UnsupportedEncodingException
- {
- //
- this.log = Logger.getLogger(PortletController.class);
-
- Map<String, String> portalProperties = new HashMap<String, String>();
- portalProperties.put("javax.portlet.markup.head.element.support", "true");
-
- this.portalContext = new AbstractPortalContext(portalProperties);
- }
-
- public void process(ControllerRequest controllerRequest) throws PortletInvokerException, IOException
- {
- if (controllerRequest instanceof ViewRequest)
- {
- render(controllerRequest.controllerContext, new ResponseProperties(), new PageNavigationalState());
- }
- else if (controllerRequest instanceof PortletRequest)
- {
- processPortletRequest((PortletRequest)controllerRequest);
- }
- else if (controllerRequest instanceof PortletResourceRequest)
- {
- processResourceRequest((PortletResourceRequest)controllerRequest);
- }
- else
- {
- throw new PortletInvokerException("Unknown request type: " + controllerRequest.getClass().getName());
- }
- }
-
- private void processPortletRequest(PortletRequest portletRequest) throws IOException, PortletInvokerException
- {
- PortletControllerContext context = portletRequest.controllerContext;
-
- //
- PortletContext portletContext = portletRequest.controllerContext.getPortlet(portletRequest.portletId).getContext();
-
- //
- PortletInvocationResponse response = invoke(portletRequest);
-
- //
- ResponseProperties requestProperties = new ResponseProperties();
-
- //
- 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());
- }
-
- //
- context.getClientResponse().sendError(404, error.getMessage());
- }
- else if (response instanceof StateResponse)
- {
- // Update portlet NS
- if (response instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
- updateNavigationalState(context, portletRequest.portletId, updateResponse, portletRequest.pageState);
-
- //
- ResponseProperties update = updateResponse.getProperties();
- if (update != null)
- {
- requestProperties.append(update);
- }
- }
-
- //
- EventControllerContext eventCC = context.getEventControllerContext();
- StateResponse stateResponse = (StateResponse)response;
-
- // Create event list and feed it with the events that may have been produced
- LinkedList<Event> eventQueue = new LinkedList<Event>();
- for (StateResponse.Event portletEvent : stateResponse.getEvents())
- {
- Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
- List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
- eventQueue.addAll(consumedEvents);
- }
-
- // Deliver events
- while (eventQueue.size() > 0)
- {
- Event event = eventQueue.removeFirst();
-
- //
- PortletInvocationResponse eventResponse = deliverEvent(context, event, portletRequest.pageState, requestProperties.getCookies());
-
- //
- if (eventResponse instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
-
- // Update ns
- updateNavigationalState(context, event.getPortletContext().getId(), update, portletRequest.pageState);
-
- // Add events if any
- for (StateResponse.Event portletEvent : update.getEvents())
- {
- Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
- List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
- eventQueue.addAll(consumedEvents);
- }
-
- //
- ResponseProperties updateProperties = update.getProperties();
- if (updateProperties != null)
- {
- requestProperties.append(updateProperties);
- }
- }
- else if (eventResponse instanceof ErrorResponse)
- {
- // Do something here !!!!
- }
- else
- {
- // Do something here !!!!
- }
- }
-
- if (response instanceof HTTPRedirectionResponse)
- {
- HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
- context.getClientResponse().sendRedirect(redirection.getLocation());
- return;
- }
- }
- else
- {
- System.out.println("Not yet handled " + response);
- }
-
- /*
- if (response instanceof RenderResponse && redirectAfterAction)
- {
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
- final RenderResponse render = (RenderResponse)response;
- String location = renderer.renderURL(new RenderURL()
- {
- public StateString getNavigationalState()
- {
- return render.getNavigationalState();
- }
- public Mode getMode()
- {
- return render.getMode();
- }
- public WindowState getWindowState()
- {
- return render.getWindowState();
- }
- }, null, null, true);
- response = new HTTPRedirectionResponse(location);
- }
- */
-
- //
- render(context, requestProperties, portletRequest.pageState);
- }
-
- private void processResourceRequest(PortletResourceRequest resourceRequest) throws IOException, PortletInvokerException
- {
- PortletInvocationResponse response = invoke(resourceRequest);
- HttpServletResponse resp = resourceRequest.controllerContext.getClientResponse();
-
- //
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
- ResponseProperties props = fragment.getProperties();
-
- //
- if (props != null)
- {
- renderTransportHeaders(props, resp);
- renderCookies(props, resp);
- }
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
- {
- resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
- else
- {
- String contentType = fragment.getContentType();
- if (contentType != null)
- {
- resp.setContentType(contentType);
- }
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
- {
- ServletOutputStream out = null;
- try
- {
- out = resp.getOutputStream();
- out.write(fragment.getBytes().toByteArray());
- }
- finally
- {
- IOTools.safeClose(out);
- }
- }
- else
- {
- Writer writer = null;
- try
- {
- writer = resp.getWriter();
- writer.write(fragment.getChars().toString());
- }
- finally
- {
- writer.close();
- }
- }
- }
- }
- else
- {
- // todo
- }
- }
-
- private PortletInvocationResponse invoke(ContainerRequest containerRequest) throws PortletInvokerException, IOException
- {
- PortletControllerContext context = containerRequest.controllerContext;
- Portlet portlet = context.getPortlet(containerRequest.portletId);
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
-
- //
- if (containerRequest instanceof PortletRenderRequest)
- {
- PortletRenderRequest portletRenderRequest = (PortletRenderRequest)containerRequest;
-
- //
- UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
- updateNavigationalState.setMode(portletRenderRequest.windowNavigationalState.getMode());
- updateNavigationalState.setWindowState(portletRenderRequest.windowNavigationalState.getWindowState());
- updateNavigationalState.setNavigationalState(portletRenderRequest.windowNavigationalState.getPortletNavigationalState());
- updateNavigationalState.setPublicNavigationalStateUpdates(portletRenderRequest.publicNavigationalStateChanges);
-
- //
- return updateNavigationalState;
- }
- else if (containerRequest instanceof PortletActionRequest)
- {
- PortletActionRequest portletActionRequest = (PortletActionRequest)containerRequest;
-
- //
- PageNavigationalState pageNS = portletActionRequest.pageState;
-
- //
- Mode mode = portletActionRequest.windowNavigationalState.getMode();
- if (mode == null)
- {
- mode = Mode.VIEW;
- }
-
- //
- WindowState windowState = portletActionRequest.windowNavigationalState.getWindowState();
- if (windowState == null)
- {
- windowState = WindowState.NORMAL;
- }
-
- //
- ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
-
- //
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, portletActionRequest.windowNavigationalState, portlet, req, resp);
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
- TestActionContext actionContext = new TestActionContext(
- renderer,
- mode,
- windowState,
- portletActionRequest.windowNavigationalState.getPortletNavigationalState(),
- publicNS,
- MARKUP_INFO,
- portletActionRequest.interactionState,
- portletActionRequest.bodyParameters != null ? ParameterMap.clone(portletActionRequest.bodyParameters) : null);
- ActionInvocation actionInvocation = new ActionInvocation(actionContext);
-
- //
- actionInvocation.setClientContext(new AbstractClientContext(req));
- actionInvocation.setServerContext(new AbstractServerContext(req, resp));
- actionInvocation.setInstanceContext(instanceContext);
- actionInvocation.setUserContext(new AbstractUserContext(req));
- actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- actionInvocation.setPortalContext(portalContext);
- actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
- actionInvocation.setRequestContext(new AbstractRequestContext(req));
- actionInvocation.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- return context.invoke(actionInvocation);
- }
- catch (PortletInvokerException e)
- {
- return null;
- }
- }
- else
- {
- PortletResourceRequest portletResourceRequest = (PortletResourceRequest)containerRequest;
-
- //
- Mode mode = null;
- WindowState windowState = null;
- PageNavigationalState pageNS = null;
- ParameterMap publicNS = null;
- StateString portletNS = null;
- CacheLevel cacheability;
-
- //
- if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
- {
- PortletScopedPortletResourceRequest portletScopedRequest = (PortletScopedPortletResourceRequest)portletResourceRequest;
- mode = portletScopedRequest.windowNavigationalState.getMode();
- windowState = portletScopedRequest.windowNavigationalState.getWindowState();
- portletNS = portletScopedRequest.windowNavigationalState.getPortletNavigationalState();
-
- //
- if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
- {
- PageScopedFullPortletResourceRequest pageScopedRequest = (PageScopedFullPortletResourceRequest)portletResourceRequest;
- pageNS = pageScopedRequest.pageState;
- cacheability = CacheLevel.PAGE;
-
- //
- if (pageNS != null)
- {
- publicNS = pageNS.getPublicNavigationalState(portlet);
- }
- }
- else
- {
- cacheability = CacheLevel.PORTLET;
- }
- }
- else
- {
- cacheability = CacheLevel.FULL;
- }
-
- //
- if (mode == null)
- {
- mode = Mode.VIEW;
- }
- if (windowState == null)
- {
- windowState = WindowState.NORMAL;
- }
-
- //
- WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode, windowState);
-
- //
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
- ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(
- portletResourceRequest.resourceId,
- cacheability,
- renderer,
- mode,
- windowState,
- portletNS,
- publicNS,
- portletResourceRequest.resourceState,
- portletResourceRequest.bodyParameters != null ? ParameterMap.clone(portletResourceRequest.bodyParameters) : null,
- MARKUP_INFO);
- ResourceInvocation resourceInvocation = new ResourceInvocation(resourceInvocationContext);
-
- //
- resourceInvocation.setClientContext(new AbstractClientContext(req));
- resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
- resourceInvocation.setInstanceContext(instanceContext);
- resourceInvocation.setUserContext(new AbstractUserContext(req));
- resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- resourceInvocation.setPortalContext(portalContext);
- resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
- resourceInvocation.setRequestContext(new AbstractRequestContext(req));
- resourceInvocation.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- return context.invoke(resourceInvocation);
- }
- catch (PortletInvokerException e)
- {
- return null;
- }
- }
- }
-
- private PortletInvocationResponse deliverEvent(
- PortletControllerContext context,
- Event event,
- PageNavigationalState pageNS,
- List<Cookie> requestCookies) throws PortletInvokerException
- {
- Portlet portlet = context.getPortlet(event.getPortletContext().getId());
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
- WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
-
- //
- if (windowNS == null)
- {
- windowNS = new WindowNavigationalState();
- }
-
- //
- ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
- TestEventContext actionContext = new TestEventContext(
- renderer,
- windowNS.getMode(),
- windowNS.getWindowState(),
- windowNS.getPortletNavigationalState(),
- publicNS,
- MARKUP_INFO,
- event.getName(),
- event.getPayload());
- EventInvocation eventInvocation = new EventInvocation(actionContext);
-
- //
- eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
- eventInvocation.setServerContext(new AbstractServerContext(req, resp));
- eventInvocation.setInstanceContext(instanceContext);
- eventInvocation.setUserContext(new AbstractUserContext(req));
- eventInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- eventInvocation.setPortalContext(portalContext);
- eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
- eventInvocation.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- return context.invoke(eventInvocation);
- }
- catch (PortletInvokerException e)
- {
- log.error("Error during event invocation", e);
-
- //
- return null;
- }
- }
-
- /**
- * @param context
- * @param pageProperties properties that needs to be rendered on this page
- * @param pageNS
- * @throws IOException
- */
- private void render(
- PortletControllerContext context,
- ResponseProperties pageProperties,
- PageNavigationalState pageNS) throws IOException
- {
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
-
- List<FragmentResponse> fragments = Collections.emptyList();
- List<ErrorResponse> errors = Collections.emptyList();
-
- // What we collect during the different renders
- // we don't reuse the render properties argument since we want to avoid that
- // a portlet rendition affects another rendition of a portlet on the same page
- ResponseProperties renderProperties = new ResponseProperties();
-
- //
- try
- {
- Collection<Portlet> portlets = context.getPortlets();
-
- int capacity = portlets.size();
- fragments = new ArrayList<FragmentResponse>(capacity);
- errors = new ArrayList<ErrorResponse>(capacity);
-
- for (Portlet portlet : portlets)
- {
- WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
-
- //
- PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
- }
-
- //
- ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
-
- //
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
- TestRenderContext renderContext = new TestRenderContext(renderer, mode, windowState, portletNS, publicNS, MARKUP_INFO);
-
- //
- RenderInvocation render = new RenderInvocation(renderContext);
-
- //
- render.setClientContext(new AbstractClientContext(req, pageProperties.getCookies()));
- render.setServerContext(new AbstractServerContext(req, resp));
- render.setInstanceContext(instanceContext);
- render.setUserContext(new AbstractUserContext(req));
- render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- render.setPortalContext(portalContext);
- render.setSecurityContext(new AbstractSecurityContext(req));
- render.setTarget(instanceContext.getTarget());
-
- //
- try
- {
- PortletInvocationResponse response = context.invoke(render);
-
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
-
- //
- fragments.add(fragment);
-
- //
- ResponseProperties fragmentProperties = fragment.getProperties();
- if (fragmentProperties != null)
- {
- renderProperties.append(fragmentProperties);
- }
- }
- else if (response instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)response;
- errors.add(error);
- }
-
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- }
- catch (PortletInvokerException e)
- {
- // todo
- e.printStackTrace();
- }
-
- // Now we combine the render properties with the page properties
- pageProperties.append(renderProperties);
-
- // Render the headers and cookies
- renderTransportHeaders(pageProperties, resp);
- renderCookies(pageProperties, resp);
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- writer.print("<html>");
-
- // Render the head contributions
- writer.print("<head>");
- MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders();
- List<Element> headElement = markupHeaders.getValues("javax.portlet.markup.head.element");
- if (headElement != null)
- {
- for (Element headerValue : headElement)
- {
- try
- {
- String serializedElement = XMLTools.toString(headerValue);
- writer.print(serializedElement);
- }
- catch (Exception e)
- {
- // todo
- e.printStackTrace();
- }
- }
- }
- writer.print("</head>");
-
-
- writer.print("<body>");
- for (FragmentResponse fragment : fragments)
- {
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
- {
- writer.print("<div class=\"portlet\">");
- writer.print(fragment.getBuffer().getContent());
- writer.print("</div>");
- }
- else
- {
- writer.print("<div/>");
- }
- }
-
- for (ErrorResponse error : errors)
- {
- writer.print("<div class='error'>");
- writer.print(error.toHTML());
- writer.print("</div>");
- }
-
- writer.print("</body></html>");
- }
-
- private void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
- {
- List<Cookie> cookies = pageProperties.getCookies();
- for (Cookie cookie : cookies)
- {
- resp.addCookie(cookie);
- }
- }
-
- private void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
- {
- MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders();
- for (String headerName : transportHeaders.keySet())
- {
- for (String headerValue : transportHeaders.getValues(headerName))
- {
- resp.addHeader(headerName, headerValue);
- }
- }
- }
-
- private void updateNavigationalState(
- PortletControllerContext context,
- String portletId,
- UpdateNavigationalStateResponse update,
- PageNavigationalState pageState) throws PortletInvokerException
- {
- Portlet portlet = context.getPortlet(portletId);
-
- //
- WindowNavigationalState windowNS = pageState.getWindowNavigationalState(portletId);
-
- //
- 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);
- pageState.setWindowNavigationalState(portletId, windowNS);
-
- // Now update shared state scoped at page
- Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
- if (publicNS != null)
- {
- NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
- Map<QName, String[]> pageNS = pageState.getPageNavigationalState();
- for (Map.Entry<String, String[]> entry : publicNS.entrySet())
- {
- String id = entry.getKey();
- ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
-
- //
- if (parameterInfo != null)
- {
- QName name = parameterInfo.getName();
- String[] value = entry.getValue();
- if (value.length > 0)
- {
- pageNS.put(name, value);
- }
- else
- {
- pageNS.remove(name);
- }
- }
- }
- }
- }
-
- /**
- * Must be used as base class for high level response provided by the controller that
- * will be translated into something at the portal level. The goal is to avoid to manipulate
- * the HTTP response directly.
- *
- * The test bed will of course use the HTTP response but the Presentation Framework will
- * work differently.
- *
- * So we really need to abstract everything done with the HttpServletResponse and *never* use
- * it in the controller.
- *
- * Typical usage should be :
- * ControllerResponse response = controller.invoker(ControllerRequest request);
- *
- */
- static class ControllerResponse
- {
-
- }
-
- static class ControllerRequest
- {
- /** . */
- final PortletControllerContext controllerContext;
-
- ControllerRequest(PortletControllerContext controllerContext)
- {
- this.controllerContext = controllerContext;
- }
- }
-
- static class ViewRequest extends ControllerRequest
- {
- ViewRequest(PortletControllerContext controllerContext)
- {
- super(controllerContext);
- }
- }
-
- static class ContainerRequest extends ControllerRequest
- {
- /** . */
- final String portletId;
-
- ContainerRequest(PortletControllerContext controllerContext, String portletId)
- {
- super(controllerContext);
-
- //
- this.portletId = portletId;
- }
- }
-
- static class PortletRequest extends ContainerRequest
- {
- /** . */
- final PageNavigationalState pageState;
-
- /** . */
- final WindowNavigationalState windowNavigationalState;
-
- PortletRequest(
- PortletControllerContext controllerContext,
- String portletId,
- WindowNavigationalState windowNavigationalState,
- PageNavigationalState pageState)
- {
- super(controllerContext, portletId);
-
- //
- this.windowNavigationalState = windowNavigationalState;
- this.pageState = pageState;
- }
- }
-
- static abstract class PortletResourceRequest extends ContainerRequest
- {
- /** . */
- private static final Map<Class, CacheLevel> cacheability = new HashMap<Class, CacheLevel>();
-
- static
- {
- cacheability.put(FullScopedCacheablePortletResourceRequest.class, CacheLevel.FULL);
- cacheability.put(PortletScopedPortletResourceRequest.class, CacheLevel.PORTLET);
- cacheability.put(PageScopedFullPortletResourceRequest.class, CacheLevel.PAGE);
- }
-
- /** . */
- final String resourceId;
-
- /** . */
- final StateString resourceState;
-
- /** . */
- final ParameterMap bodyParameters;
-
- PortletResourceRequest(
- PortletControllerContext controllerContext,
- String portletId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters
- )
- {
- super(controllerContext, portletId);
-
- //
- this.resourceId = resourceId;
- this.resourceState = resourceState;
- this.bodyParameters = bodyParameters;
- }
-
- public CacheLevel getCacheabilityType()
- {
- return cacheability.get(getClass());
- }
- }
-
- static class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
- {
- FullScopedCacheablePortletResourceRequest(
- PortletControllerContext controllerContext,
- String portletId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters)
- {
- super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
- }
- }
-
- static class PortletScopedPortletResourceRequest extends FullScopedCacheablePortletResourceRequest
- {
- /** . */
- final WindowNavigationalState windowNavigationalState;
-
- PortletScopedPortletResourceRequest(
- PortletControllerContext controllerContext,
- String portletId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- WindowNavigationalState windowNavigationalState)
- {
- super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
-
- //
- this.windowNavigationalState = windowNavigationalState;
- }
- }
-
- static class PageScopedFullPortletResourceRequest extends PortletScopedPortletResourceRequest
- {
- /** . */
- private final PageNavigationalState pageState;
-
- PageScopedFullPortletResourceRequest(
- PortletControllerContext controllerContext,
- String portletId,
- String resourceId,
- StateString resourceState,
- ParameterMap bodyParameters,
- PageNavigationalState pageState,
- WindowNavigationalState windowNavigationalState)
- {
- super(controllerContext, portletId, resourceId, resourceState, bodyParameters, windowNavigationalState);
-
- //
- this.pageState = pageState;
- }
- }
-
- static class PortletActionRequest extends PortletRequest
- {
- /** . */
- final StateString interactionState;
-
- /** . */
- final ParameterMap bodyParameters;
-
- public PortletActionRequest(
- PortletControllerContext controllerContext,
- String portletId,
- StateString interactionState,
- ParameterMap bodyParameters,
- WindowNavigationalState windowNavigationalState,
- PageNavigationalState pageState)
- {
- super(controllerContext, portletId, windowNavigationalState, pageState);
-
- //
- this.interactionState = interactionState;
- this.bodyParameters = bodyParameters;
- }
- }
-
- static class PortletRenderRequest extends PortletRequest
- {
- /** . */
- final Map<String, String[]> publicNavigationalStateChanges;
-
- public PortletRenderRequest(
- PortletControllerContext controllerContext,
- String portletId,
- WindowNavigationalState windowNavigationalState,
- Map<String, String[]> publicNavigationalStateChanges,
- PageNavigationalState pageState)
- {
- super(controllerContext, portletId, windowNavigationalState, pageState);
-
- //
- this.publicNavigationalStateChanges = publicNavigationalStateChanges;
- }
- }
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-31 23:10:24 UTC (rev 9689)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -1,57 +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.test;
-
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.test.event.EventControllerContext;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletContext;
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface PortletControllerContext
-{
-
- ServletContext getServletContext();
-
- HttpServletRequest getClientRequest();
-
- HttpServletResponse getClientResponse();
-
- Portlet getPortlet(String portletId) throws PortletInvokerException;
-
- PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException;
-
- Collection<Portlet> getPortlets() throws PortletInvokerException;
-
- EventControllerContext getEventControllerContext();
-
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-31 23:10:24 UTC (rev 9689)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -1,280 +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.test;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.cache.CacheLevel;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.web.Body;
-import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.web.WebRequest;
-import static org.jboss.portal.portlet.test.URLParameterConstants.*;
-import org.jboss.portal.portlet.test.event.EventControllerContext;
-import org.jboss.portal.portlet.test.event.EventControllerContextImpl;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletControllerContextImpl implements PortletControllerContext
-{
-
- /** . */
- public static final int NAV_SCOPE = 0;
-
- /** . */
- public static final int SESSION_SCOPE = 1;
-
- /** . */
- private final HttpServletRequest req;
-
- /** . */
- private final HttpServletResponse resp;
-
- /** . */
- private final ServletContext servletContext;
-
- /** . */
- private final PortletController.ControllerRequest request;
-
- /** . */
- private final PortletInvoker invoker;
-
- /** . */
- private final EventControllerContext eventControllerContext;
-
- public PortletControllerContextImpl(
- HttpServletRequest req,
- HttpServletResponse resp,
- ServletContext servletContext)
- throws IllegalRequestException, IOException, ClassNotFoundException
- {
- PortletInvoker invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
-
- // The nav state provided with the request
- PageNavigationalState pageState = null;
-
- // The request decoded if not null
- PortletController.ControllerRequest request = null;
-
- // Process
- String pathInfo = req.getPathInfo();
- if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
- {
- // Get the target portlet
- String targetId = StringCodec.decode(pathInfo.substring(1));
-
- // Helper
- WebRequest ri = new WebRequest(req);
-
- // Unmarshall portal navigational state if it is provided
- String context = req.getParameter(PAGE_STATE);
- if (context != null)
- {
- byte[] bytes = Tools.fromHexString(context);
- pageState = PageNavigationalState.unserialize(bytes);
- }
-
- //
- Mode mode = null;
- if (req.getParameter(MODE) != null)
- {
- mode = Mode.create(req.getParameter(MODE));
- }
-
- //
- WindowState windowState = null;
- if (req.getParameter(WINDOW_STATE) != null)
- {
- windowState = WindowState.create(req.getParameter(WINDOW_STATE));
- }
-
- //
- String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
- StateString navigationalState = null;
- if (navigationalStateString != null)
- {
- navigationalState = ParametersStateString.create(navigationalStateString);
- }
-
- //
- WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
-
- //
- String type = req.getParameter(LIFECYCLE_TYPE);
- if (RESOURCE_LIFECYCLE.equals(type))
- {
- StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
- String resourceId = req.getParameter(RESOURCE_ID);
-
-
- //
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
- //
- CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
-
- //
- switch (resourceCacheLevel)
- {
- case FULL:
- request = new PortletController.FullScopedCacheablePortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters);
- break;
- case PORTLET:
- request = new PortletController.PortletScopedPortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters,
- windowNavigationalState);
- break;
- case PAGE:
- request = new PortletController.PageScopedFullPortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters,
- pageState,
- windowNavigationalState);
- break;
- }
- }
- else
- {
- if (ACTION_LIFECYCLE.equals(type))
- {
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
- //
- StateString interactionState = ParametersStateString.create(req.getParameter(INTERACTION_STATE));
-
- //
- request = new PortletController.PortletActionRequest(
- this,
- targetId,
- interactionState,
- formParameters,
- windowNavigationalState,
- pageState);
- }
- else
- {
- Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
-
- //
- request = new PortletController.PortletRenderRequest(
- this,
- targetId,
- windowNavigationalState,
- publicNavigationalStateChanges,
- pageState);
- }
- }
- }
- else
- {
- request = new PortletController.ViewRequest(this);
- }
-
- //
- this.request = request;
- this.req = req;
- this.resp = resp;
- this.servletContext = servletContext;
- this.invoker = invoker;
- this.eventControllerContext = new EventControllerContextImpl(invoker);
- }
-
- public PortletController.ControllerRequest getRequest()
- {
- return request;
- }
-
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- public HttpServletRequest getClientRequest()
- {
- return req;
- }
-
- public HttpServletResponse getClientResponse()
- {
- return resp;
- }
-
- public Portlet getPortlet(String portletId) throws PortletInvokerException
- {
- return invoker.getPortlet(PortletContext.createPortletContext(portletId));
- }
-
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
- {
- return invoker.invoke(invocation);
- }
-
- public Collection<Portlet> getPortlets() throws PortletInvokerException
- {
- return invoker.getPortlets();
- }
-
- public EventControllerContext getEventControllerContext()
- {
- return eventControllerContext;
- }
-}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java (from rev 9688, 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/controller/PortletController.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletController.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,669 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.common.util.MultiValuedPropertyMap;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.PortletURLRenderer;
+import org.jboss.portal.portlet.test.TestEventContext;
+import org.jboss.portal.portlet.test.TestInstanceContext;
+import org.jboss.portal.portlet.test.TestRenderContext;
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+import org.jboss.portal.portlet.test.event.Event;
+import org.jboss.portal.web.IllegalRequestException;
+import org.w3c.dom.Element;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletController
+{
+
+ /** . */
+ static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
+
+ /** . */
+ // private final boolean redirectAfterAction = true;
+
+ /** . */
+ private final Logger log;
+
+ /** . */
+ private final PortalContext portalContext;
+
+ public PortletController() throws IllegalRequestException, UnsupportedEncodingException
+ {
+ //
+ this.log = Logger.getLogger(PortletController.class);
+
+ Map<String, String> portalProperties = new HashMap<String, String>();
+ portalProperties.put("javax.portlet.markup.head.element.support", "true");
+
+ this.portalContext = new AbstractPortalContext(portalProperties);
+ }
+
+ public void process(ControllerRequest controllerRequest) throws IOException, PortletInvokerException
+ {
+ RequestHandler handler;
+
+ if (controllerRequest instanceof ViewRequest)
+ {
+ handler = new ViewRequestHandler(this);
+ }
+ else if (controllerRequest instanceof PortletRequest)
+ {
+ handler = new PortletRequestHandler(this);
+ }
+ else if (controllerRequest instanceof PortletResourceRequest)
+ {
+ handler = new PortletResourceRequestHandler(this);
+ }
+ else
+ {
+ throw new PortletInvokerException("Unknown request type: " + controllerRequest.getClass().getName());
+ }
+
+ handler.handle(controllerRequest);
+ }
+
+ PortletInvocationResponse deliverEvent(
+ PortletControllerContext context,
+ Event event,
+ PageNavigationalState pageNS,
+ List<Cookie> requestCookies) throws PortletInvokerException
+ {
+ Portlet portlet = context.getPortlet(event.getPortletContext().getId());
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
+
+ //
+ if (windowNS == null)
+ {
+ windowNS = new WindowNavigationalState();
+ }
+
+ //
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ TestEventContext actionContext = new TestEventContext(
+ renderer,
+ windowNS.getMode(),
+ windowNS.getWindowState(),
+ windowNS.getPortletNavigationalState(),
+ publicNS,
+ MARKUP_INFO,
+ event.getName(),
+ event.getPayload());
+ EventInvocation eventInvocation = new EventInvocation(actionContext);
+
+ //
+ eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
+ eventInvocation.setServerContext(new AbstractServerContext(req, resp));
+ eventInvocation.setInstanceContext(instanceContext);
+ eventInvocation.setUserContext(new AbstractUserContext(req));
+ eventInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ eventInvocation.setPortalContext(getPortalContext());
+ eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ eventInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(eventInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Error during event invocation", e);
+
+ //
+ return null;
+ }
+ }
+
+ /**
+ * @param context
+ * @param pageProperties properties that needs to be rendered on this page
+ * @param pageNS
+ * @throws IOException
+ */
+ void render(PortletControllerContext context, ResponseProperties pageProperties, PageNavigationalState pageNS) throws IOException
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+
+ List<FragmentResponse> fragments = Collections.emptyList();
+ List<ErrorResponse> errors = Collections.emptyList();
+
+ // What we collect during the different renders
+ // we don't reuse the render properties argument since we want to avoid that
+ // a portlet rendition affects another rendition of a portlet on the same page
+ ResponseProperties renderProperties = new ResponseProperties();
+
+ //
+ try
+ {
+ Collection<Portlet> portlets = context.getPortlets();
+
+ int capacity = portlets.size();
+ fragments = new ArrayList<FragmentResponse>(capacity);
+ errors = new ArrayList<ErrorResponse>(capacity);
+
+ for (Portlet portlet : portlets)
+ {
+ WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
+
+ //
+ Mode mode = Mode.VIEW;
+ WindowState windowState = WindowState.NORMAL;
+ StateString portletNS = null;
+
+ //
+ if (windowNS != null)
+ {
+ if (windowNS.getMode() != null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ portletNS = windowNS.getPortletNavigationalState();
+ }
+ }
+
+ //
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), false);
+ TestRenderContext renderContext = new TestRenderContext(renderer, mode, windowState, portletNS, publicNS, MARKUP_INFO);
+
+ //
+ RenderInvocation render = new RenderInvocation(renderContext);
+
+ //
+ render.setClientContext(new AbstractClientContext(req, pageProperties.getCookies()));
+ render.setServerContext(new AbstractServerContext(req, resp));
+ render.setInstanceContext(instanceContext);
+ render.setUserContext(new AbstractUserContext(req));
+ render.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ render.setPortalContext(getPortalContext());
+ render.setSecurityContext(new AbstractSecurityContext(req));
+ render.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ PortletInvocationResponse response = context.invoke(render);
+
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+
+ //
+ fragments.add(fragment);
+
+ //
+ ResponseProperties fragmentProperties = fragment.getProperties();
+ if (fragmentProperties != null)
+ {
+ renderProperties.append(fragmentProperties);
+ }
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)response;
+ errors.add(error);
+ }
+
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+
+ // Now we combine the render properties with the page properties
+ pageProperties.append(renderProperties);
+
+ // Render the headers and cookies
+ renderTransportHeaders(pageProperties, resp);
+ renderCookies(pageProperties, resp);
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ writer.print("<html>");
+
+ // Render the head contributions
+ writer.print("<head>");
+ MultiValuedPropertyMap<Element> markupHeaders = pageProperties.getMarkupHeaders();
+ List<Element> headElement = markupHeaders.getValues("javax.portlet.markup.head.element");
+ if (headElement != null)
+ {
+ for (Element headerValue : headElement)
+ {
+ try
+ {
+ String serializedElement = XMLTools.toString(headerValue);
+ writer.print(serializedElement);
+ }
+ catch (Exception e)
+ {
+ // todo
+ e.printStackTrace();
+ }
+ }
+ }
+ writer.print("</head>");
+
+
+ writer.print("<body>");
+ for (FragmentResponse fragment : fragments)
+ {
+ if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ {
+ writer.print("<div class=\"portlet\">");
+ writer.print(fragment.getBuffer().getContent());
+ writer.print("</div>");
+ }
+ else
+ {
+ writer.print("<div/>");
+ }
+ }
+
+ for (ErrorResponse error : errors)
+ {
+ writer.print("<div class='error'>");
+ writer.print(error.toHTML());
+ writer.print("</div>");
+ }
+
+ writer.print("</body></html>");
+ }
+
+ void renderCookies(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ List<Cookie> cookies = pageProperties.getCookies();
+ for (Cookie cookie : cookies)
+ {
+ resp.addCookie(cookie);
+ }
+ }
+
+ void renderTransportHeaders(ResponseProperties pageProperties, HttpServletResponse resp)
+ {
+ MultiValuedPropertyMap<String> transportHeaders = pageProperties.getTransportHeaders();
+ for (String headerName : transportHeaders.keySet())
+ {
+ for (String headerValue : transportHeaders.getValues(headerName))
+ {
+ resp.addHeader(headerName, headerValue);
+ }
+ }
+ }
+
+ void updateNavigationalState(
+ PortletControllerContext context,
+ String portletId,
+ UpdateNavigationalStateResponse update,
+ PageNavigationalState pageState) throws PortletInvokerException
+ {
+ Portlet portlet = context.getPortlet(portletId);
+
+ //
+ WindowNavigationalState windowNS = pageState.getWindowNavigationalState(portletId);
+
+ //
+ 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);
+ pageState.setWindowNavigationalState(portletId, windowNS);
+
+ // Now update shared state scoped at page
+ Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
+ if (publicNS != null)
+ {
+ NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
+ Map<QName, String[]> pageNS = pageState.getPageNavigationalState();
+ for (Map.Entry<String, String[]> entry : publicNS.entrySet())
+ {
+ String id = entry.getKey();
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
+
+ //
+ if (parameterInfo != null)
+ {
+ QName name = parameterInfo.getName();
+ String[] value = entry.getValue();
+ if (value.length > 0)
+ {
+ pageNS.put(name, value);
+ }
+ else
+ {
+ pageNS.remove(name);
+ }
+ }
+ }
+ }
+ }
+
+ PortalContext getPortalContext()
+ {
+ return portalContext;
+ }
+
+ /**
+ * Must be used as base class for high level response provided by the controller that will be translated into
+ * something at the portal level. The goal is to avoid to manipulate the HTTP response directly.
+ * <p/>
+ * The test bed will of course use the HTTP response but the Presentation Framework will work differently.
+ * <p/>
+ * So we really need to abstract everything done with the HttpServletResponse and *never* use it in the controller.
+ * <p/>
+ * Typical usage should be : ControllerResponse response = controller.invoker(ControllerRequest request);
+ */
+ static class ControllerResponse
+ {
+
+ }
+
+ static class ControllerRequest
+ {
+ /** . */
+ final PortletControllerContext controllerContext;
+
+ ControllerRequest(PortletControllerContext controllerContext)
+ {
+ this.controllerContext = controllerContext;
+ }
+ }
+
+ static class ViewRequest extends ControllerRequest
+ {
+ ViewRequest(PortletControllerContext controllerContext)
+ {
+ super(controllerContext);
+ }
+ }
+
+ static class ContainerRequest extends ControllerRequest
+ {
+ /** . */
+ final String portletId;
+
+ ContainerRequest(PortletControllerContext controllerContext, String portletId)
+ {
+ super(controllerContext);
+
+ //
+ this.portletId = portletId;
+ }
+ }
+
+ static class PortletRequest extends ContainerRequest
+ {
+ /** . */
+ final PageNavigationalState pageState;
+
+ /** . */
+ final WindowNavigationalState windowNavigationalState;
+
+ PortletRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ WindowNavigationalState windowNavigationalState,
+ PageNavigationalState pageState)
+ {
+ super(controllerContext, portletId);
+
+ //
+ this.windowNavigationalState = windowNavigationalState;
+ this.pageState = pageState;
+ }
+ }
+
+ static abstract class PortletResourceRequest extends ContainerRequest
+ {
+ /** . */
+ private static final Map<Class, CacheLevel> cacheability = new HashMap<Class, CacheLevel>();
+
+ static
+ {
+ cacheability.put(FullScopedCacheablePortletResourceRequest.class, CacheLevel.FULL);
+ cacheability.put(PortletScopedPortletResourceRequest.class, CacheLevel.PORTLET);
+ cacheability.put(PageScopedFullPortletResourceRequest.class, CacheLevel.PAGE);
+ }
+
+ /** . */
+ final String resourceId;
+
+ /** . */
+ final StateString resourceState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ PortletResourceRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters
+ )
+ {
+ super(controllerContext, portletId);
+
+ //
+ this.resourceId = resourceId;
+ this.resourceState = resourceState;
+ this.bodyParameters = bodyParameters;
+ }
+
+ public CacheLevel getCacheabilityType()
+ {
+ return cacheability.get(getClass());
+ }
+ }
+
+ static class FullScopedCacheablePortletResourceRequest extends PortletResourceRequest
+ {
+ FullScopedCacheablePortletResourceRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters)
+ {
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
+ }
+ }
+
+ static class PortletScopedPortletResourceRequest extends FullScopedCacheablePortletResourceRequest
+ {
+ /** . */
+ final WindowNavigationalState windowNavigationalState;
+
+ PortletScopedPortletResourceRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ WindowNavigationalState windowNavigationalState)
+ {
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters);
+
+ //
+ this.windowNavigationalState = windowNavigationalState;
+ }
+ }
+
+ static class PageScopedFullPortletResourceRequest extends PortletScopedPortletResourceRequest
+ {
+ /** . */
+ private final PageNavigationalState pageState;
+
+ PageScopedFullPortletResourceRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ PageNavigationalState pageState,
+ WindowNavigationalState windowNavigationalState)
+ {
+ super(controllerContext, portletId, resourceId, resourceState, bodyParameters, windowNavigationalState);
+
+ //
+ this.pageState = pageState;
+ }
+
+ PageNavigationalState getPageState()
+ {
+ return pageState;
+ }
+ }
+
+ static class PortletActionRequest extends PortletRequest
+ {
+ /** . */
+ final StateString interactionState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ public PortletActionRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ StateString interactionState,
+ ParameterMap bodyParameters,
+ WindowNavigationalState windowNavigationalState,
+ PageNavigationalState pageState)
+ {
+ super(controllerContext, portletId, windowNavigationalState, pageState);
+
+ //
+ this.interactionState = interactionState;
+ this.bodyParameters = bodyParameters;
+ }
+ }
+
+ static class PortletRenderRequest extends PortletRequest
+ {
+ /** . */
+ final Map<String, String[]> publicNavigationalStateChanges;
+
+ public PortletRenderRequest(
+ PortletControllerContext controllerContext,
+ String portletId,
+ WindowNavigationalState windowNavigationalState,
+ Map<String, String[]> publicNavigationalStateChanges,
+ PageNavigationalState pageState)
+ {
+ super(controllerContext, portletId, windowNavigationalState, pageState);
+
+ //
+ this.publicNavigationalStateChanges = publicNavigationalStateChanges;
+ }
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContext.java (from rev 9688, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContext.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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.controller;
+
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletControllerContext
+{
+
+ ServletContext getServletContext();
+
+ HttpServletRequest getClientRequest();
+
+ HttpServletResponse getClientResponse();
+
+ Portlet getPortlet(String portletId) throws PortletInvokerException;
+
+ PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException;
+
+ Collection<Portlet> getPortlets() throws PortletInvokerException;
+
+ EventControllerContext getEventControllerContext();
+
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java (from rev 9688, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,282 @@
+/******************************************************************************
+ * 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.controller;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.StringCodec;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
+import org.jboss.portal.portlet.test.event.EventControllerContextImpl;
+import org.jboss.portal.web.Body;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.web.WebRequest;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletControllerContextImpl implements PortletControllerContext
+{
+
+ /** . */
+ public static final int NAV_SCOPE = 0;
+
+ /** . */
+ public static final int SESSION_SCOPE = 1;
+
+ /** . */
+ private final HttpServletRequest req;
+
+ /** . */
+ private final HttpServletResponse resp;
+
+ /** . */
+ private final ServletContext servletContext;
+
+ /** . */
+ private final PortletController.ControllerRequest request;
+
+ /** . */
+ private final PortletInvoker invoker;
+
+ /** . */
+ private final EventControllerContext eventControllerContext;
+
+ public PortletControllerContextImpl(
+ HttpServletRequest req,
+ HttpServletResponse resp,
+ ServletContext servletContext)
+ throws IllegalRequestException, IOException, ClassNotFoundException
+ {
+ PortletInvoker invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+
+ // The nav state provided with the request
+ PageNavigationalState pageState = null;
+
+ // The request decoded if not null
+ PortletController.ControllerRequest request = null;
+
+ // Process
+ String pathInfo = req.getPathInfo();
+ if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
+ {
+ // Get the target portlet
+ String targetId = StringCodec.decode(pathInfo.substring(1));
+
+ // Helper
+ WebRequest ri = new WebRequest(req);
+
+ // Unmarshall portal navigational state if it is provided
+ String context = req.getParameter(PAGE_STATE);
+ if (context != null)
+ {
+ byte[] bytes = Tools.fromHexString(context);
+ pageState = PageNavigationalState.unserialize(bytes);
+ }
+
+ //
+ Mode mode = null;
+ if (req.getParameter(MODE) != null)
+ {
+ mode = Mode.create(req.getParameter(MODE));
+ }
+
+ //
+ WindowState windowState = null;
+ if (req.getParameter(WINDOW_STATE) != null)
+ {
+ windowState = WindowState.create(req.getParameter(WINDOW_STATE));
+ }
+
+ //
+ String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
+ StateString navigationalState = null;
+ if (navigationalStateString != null)
+ {
+ navigationalState = ParametersStateString.create(navigationalStateString);
+ }
+
+ //
+ WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
+
+ //
+ String type = req.getParameter(LIFECYCLE_TYPE);
+ if (RESOURCE_LIFECYCLE.equals(type))
+ {
+ StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
+ String resourceId = req.getParameter(RESOURCE_ID);
+
+ //
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
+
+ //
+ switch (resourceCacheLevel)
+ {
+ case FULL:
+ request = new PortletController.FullScopedCacheablePortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters);
+ break;
+ case PORTLET:
+ request = new PortletController.PortletScopedPortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ windowNavigationalState);
+ break;
+ case PAGE:
+ request = new PortletController.PageScopedFullPortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ pageState,
+ windowNavigationalState);
+ break;
+ }
+ }
+ else
+ {
+ if (ACTION_LIFECYCLE.equals(type))
+ {
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ StateString interactionState = ParametersStateString.create(req.getParameter(INTERACTION_STATE));
+
+ //
+ request = new PortletController.PortletActionRequest(
+ this,
+ targetId,
+ interactionState,
+ formParameters,
+ windowNavigationalState,
+ pageState);
+ }
+ else
+ {
+ Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
+
+ //
+ request = new PortletController.PortletRenderRequest(
+ this,
+ targetId,
+ windowNavigationalState,
+ publicNavigationalStateChanges,
+ pageState);
+ }
+ }
+ }
+ else
+ {
+ request = new PortletController.ViewRequest(this);
+ }
+
+ //
+ this.request = request;
+ this.req = req;
+ this.resp = resp;
+ this.servletContext = servletContext;
+ this.invoker = invoker;
+ this.eventControllerContext = new EventControllerContextImpl(invoker);
+ }
+
+ public PortletController.ControllerRequest getRequest()
+ {
+ return request;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return req;
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return resp;
+ }
+
+ public Portlet getPortlet(String portletId) throws PortletInvokerException
+ {
+ return invoker.getPortlet(PortletContext.createPortletContext(portletId));
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ return invoker.invoke(invocation);
+ }
+
+ public Collection<Portlet> getPortlets() throws PortletInvokerException
+ {
+ return invoker.getPortlets();
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2008, Your Corporation. All Rights Reserved.
+ */
+
+package org.jboss.portal.portlet.test.controller;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.invocation.response.StateResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.PortletURLRenderer;
+import org.jboss.portal.portlet.test.TestActionContext;
+import org.jboss.portal.portlet.test.TestInstanceContext;
+import static org.jboss.portal.portlet.test.controller.PortletController.*;
+import org.jboss.portal.portlet.test.event.Event;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class PortletRequestHandler extends RequestHandler<PortletRequest>
+{
+ public PortletRequestHandler(PortletController controller)
+ {
+ super(controller);
+ }
+
+ protected PortletRequest downcastRequest(ControllerRequest request)
+ {
+ if (!(request instanceof PortletRequest))
+ {
+ throw new IllegalArgumentException("Request " + request + " cannot be handled by this handler");
+ }
+
+ return (PortletRequest)request;
+ }
+
+ void processResponse(PortletRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ {
+ PortletRequest portletRequest = downcastRequest(request);
+
+ PortletControllerContext context = portletRequest.controllerContext;
+
+ //
+ PortletContext portletContext = portletRequest.controllerContext.getPortlet(portletRequest.portletId).getContext();
+ //
+ ResponseProperties requestProperties = new ResponseProperties();
+
+ //
+ 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());
+ }
+
+ //
+ context.getClientResponse().sendError(404, error.getMessage());
+ }
+ else if (response instanceof StateResponse)
+ {
+ // Update portlet NS
+ if (response instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse updateResponse = (UpdateNavigationalStateResponse)response;
+ controller.updateNavigationalState(context, portletRequest.portletId, updateResponse, portletRequest.pageState);
+
+ //
+ ResponseProperties update = updateResponse.getProperties();
+ if (update != null)
+ {
+ requestProperties.append(update);
+ }
+ }
+
+ //
+ EventControllerContext eventCC = context.getEventControllerContext();
+ StateResponse stateResponse = (StateResponse)response;
+
+ // Create event list and feed it with the events that may have been produced
+ LinkedList<Event> eventQueue = new LinkedList<Event>();
+ for (StateResponse.Event portletEvent : stateResponse.getEvents())
+ {
+ Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
+ List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
+ eventQueue.addAll(consumedEvents);
+ }
+
+ // Deliver events
+ while (eventQueue.size() > 0)
+ {
+ Event event = eventQueue.removeFirst();
+
+ //
+ PortletInvocationResponse eventResponse = controller.deliverEvent(context, event, portletRequest.pageState, requestProperties.getCookies());
+
+ //
+ if (eventResponse instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
+
+ // Update ns
+ controller.updateNavigationalState(context, event.getPortletContext().getId(), update, portletRequest.pageState);
+
+ // Add events if any
+ for (StateResponse.Event portletEvent : update.getEvents())
+ {
+ Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
+ List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
+ eventQueue.addAll(consumedEvents);
+ }
+
+ //
+ ResponseProperties updateProperties = update.getProperties();
+ if (updateProperties != null)
+ {
+ requestProperties.append(updateProperties);
+ }
+ }
+ else if (eventResponse instanceof ErrorResponse)
+ {
+ // Do something here !!!!
+ }
+ else
+ {
+ // Do something here !!!!
+ }
+ }
+
+ if (response instanceof HTTPRedirectionResponse)
+ {
+ HTTPRedirectionResponse redirection = (HTTPRedirectionResponse)response;
+ context.getClientResponse().sendRedirect(redirection.getLocation());
+ return;
+ }
+ }
+ else
+ {
+ System.out.println("Not yet handled " + response);
+ }
+
+ /*
+ if (response instanceof RenderResponse && redirectAfterAction)
+ {
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req, resp);
+ final RenderResponse render = (RenderResponse)response;
+ String location = renderer.renderURL(new RenderURL()
+ {
+ public StateString getNavigationalState()
+ {
+ return render.getNavigationalState();
+ }
+ public Mode getMode()
+ {
+ return render.getMode();
+ }
+ public WindowState getWindowState()
+ {
+ return render.getWindowState();
+ }
+ }, null, null, true);
+ response = new HTTPRedirectionResponse(location);
+ }
+ */
+
+ //
+ controller.render(context, requestProperties, portletRequest.pageState);
+ }
+
+ PortletInvocationResponse invoke(PortletRequest controllerRequest) throws PortletInvokerException
+ {
+ PortletRequest portletRequest = downcastRequest(controllerRequest);
+
+ PortletControllerContext context = portletRequest.controllerContext;
+ Portlet portlet = context.getPortlet(portletRequest.portletId);
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+
+ //
+ if (portletRequest instanceof PortletRenderRequest)
+ {
+ PortletRenderRequest portletRenderRequest = (PortletRenderRequest)portletRequest;
+
+ //
+ UpdateNavigationalStateResponse updateNavigationalState = new UpdateNavigationalStateResponse();
+ updateNavigationalState.setMode(portletRenderRequest.windowNavigationalState.getMode());
+ updateNavigationalState.setWindowState(portletRenderRequest.windowNavigationalState.getWindowState());
+ updateNavigationalState.setNavigationalState(portletRenderRequest.windowNavigationalState.getPortletNavigationalState());
+ updateNavigationalState.setPublicNavigationalStateUpdates(portletRenderRequest.publicNavigationalStateChanges);
+
+ //
+ return updateNavigationalState;
+ }
+ else
+ {
+ PortletActionRequest portletActionRequest = (PortletActionRequest)portletRequest;
+
+ //
+ PageNavigationalState pageNS = portletActionRequest.pageState;
+
+ //
+ Mode mode = portletActionRequest.windowNavigationalState.getMode();
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ //
+ WindowState windowState = portletActionRequest.windowNavigationalState.getWindowState();
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+
+ //
+ ParameterMap publicNS = pageNS.getPublicNavigationalState(portlet);
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, portletActionRequest.windowNavigationalState, portlet, req, resp);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ TestActionContext actionContext = new TestActionContext(
+ renderer,
+ mode,
+ windowState,
+ portletActionRequest.windowNavigationalState.getPortletNavigationalState(),
+ publicNS,
+ MARKUP_INFO,
+ portletActionRequest.interactionState,
+ portletActionRequest.bodyParameters != null ? ParameterMap.clone(portletActionRequest.bodyParameters) : null);
+ ActionInvocation actionInvocation = new ActionInvocation(actionContext);
+
+ //
+ actionInvocation.setClientContext(new AbstractClientContext(req));
+ actionInvocation.setServerContext(new AbstractServerContext(req, resp));
+ actionInvocation.setInstanceContext(instanceContext);
+ actionInvocation.setUserContext(new AbstractUserContext(req));
+ actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ actionInvocation.setPortalContext(controller.getPortalContext());
+ actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ actionInvocation.setRequestContext(new AbstractRequestContext(req));
+ actionInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(actionInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
+ }
+ }
+
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletRequestHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+import org.jboss.portal.portlet.test.PageNavigationalState;
+import org.jboss.portal.portlet.test.PortletURLRenderer;
+import org.jboss.portal.portlet.test.ResourceTestContext;
+import org.jboss.portal.portlet.test.TestInstanceContext;
+import org.jboss.portal.portlet.test.WindowNavigationalState;
+import static org.jboss.portal.portlet.test.controller.PortletController.*;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class PortletResourceRequestHandler extends RequestHandler<PortletResourceRequest>
+{
+ public PortletResourceRequestHandler(PortletController controller)
+ {
+ super(controller);
+ }
+
+ void processResponse(PortletResourceRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ {
+ HttpServletResponse resp = request.controllerContext.getClientResponse();
+
+ //
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ ResponseProperties props = fragment.getProperties();
+
+ //
+ if (props != null)
+ {
+ controller.renderTransportHeaders(props, resp);
+ controller.renderCookies(props, resp);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = fragment.getContentType();
+ if (contentType != null)
+ {
+ resp.setContentType(contentType);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = resp.getOutputStream();
+ out.write(fragment.getBytes().toByteArray());
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ writer.write(fragment.getChars().toString());
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ }
+ }
+ else
+ {
+ // todo
+ }
+ }
+
+ PortletInvocationResponse invoke(PortletResourceRequest portletResourceRequest) throws PortletInvokerException
+ {
+
+ //
+ Mode mode = null;
+ WindowState windowState = null;
+ PageNavigationalState pageNS = null;
+ ParameterMap publicNS = null;
+ StateString portletNS = null;
+ CacheLevel cacheability;
+
+ PortletControllerContext context = portletResourceRequest.controllerContext;
+ Portlet portlet = context.getPortlet(portletResourceRequest.portletId);
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+
+ //
+ if (portletResourceRequest instanceof PortletScopedPortletResourceRequest)
+ {
+ PortletScopedPortletResourceRequest portletScopedRequest = (PortletScopedPortletResourceRequest)portletResourceRequest;
+ mode = portletScopedRequest.windowNavigationalState.getMode();
+ windowState = portletScopedRequest.windowNavigationalState.getWindowState();
+ portletNS = portletScopedRequest.windowNavigationalState.getPortletNavigationalState();
+
+ //
+ if (portletResourceRequest instanceof PageScopedFullPortletResourceRequest)
+ {
+ PageScopedFullPortletResourceRequest pageScopedRequest = (PageScopedFullPortletResourceRequest)portletResourceRequest;
+ pageNS = pageScopedRequest.getPageState();
+ cacheability = CacheLevel.PAGE;
+
+ //
+ if (pageNS != null)
+ {
+ publicNS = pageNS.getPublicNavigationalState(portlet);
+ }
+ }
+ else
+ {
+ cacheability = CacheLevel.PORTLET;
+ }
+ }
+ else
+ {
+ cacheability = CacheLevel.FULL;
+ }
+
+ //
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+
+ //
+ WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode, windowState);
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(pageNS, windowNS, portlet, req, resp);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+ ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(
+ portletResourceRequest.resourceId,
+ cacheability,
+ renderer,
+ mode,
+ windowState,
+ portletNS,
+ publicNS,
+ portletResourceRequest.resourceState,
+ portletResourceRequest.bodyParameters != null ? ParameterMap.clone(portletResourceRequest.bodyParameters) : null,
+ MARKUP_INFO);
+ ResourceInvocation resourceInvocation = new ResourceInvocation(resourceInvocationContext);
+
+ //
+ resourceInvocation.setClientContext(new AbstractClientContext(req));
+ resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
+ resourceInvocation.setInstanceContext(instanceContext);
+ resourceInvocation.setUserContext(new AbstractUserContext(req));
+ resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ resourceInvocation.setPortalContext(controller.getPortalContext());
+ resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ resourceInvocation.setRequestContext(new AbstractRequestContext(req));
+ resourceInvocation.setTarget(instanceContext.getTarget());
+
+ //
+ try
+ {
+ return context.invoke(resourceInvocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ return null;
+ }
+ }
+
+ PortletResourceRequest downcastRequest(ControllerRequest request)
+ {
+ if (!(request instanceof PortletResourceRequest))
+ {
+ throw new IllegalArgumentException("Request " + request + " cannot be handled by this handler");
+ }
+
+ return (PortletResourceRequest)request;
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletResourceRequestHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008, Your Corporation. All Rights Reserved.
+ */
+
+package org.jboss.portal.portlet.test.controller;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import static org.jboss.portal.portlet.test.controller.PortletController.ControllerRequest;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public abstract class RequestHandler<T extends ControllerRequest>
+{
+ protected PortletController controller;
+
+ protected static final Logger log = Logger.getLogger(RequestHandler.class);
+
+ public RequestHandler(PortletController controller)
+ {
+ this.controller = controller;
+ }
+
+ public void handle(ControllerRequest request) throws PortletInvokerException, IOException
+ {
+ T req = downcastRequest(request);
+ PortletInvocationResponse response = invoke(req);
+
+ processResponse(req, response);
+ }
+
+ abstract void processResponse(T request, PortletInvocationResponse response) throws IOException, PortletInvokerException;
+
+ abstract PortletInvocationResponse invoke(T controllerRequest) throws PortletInvokerException;
+
+ abstract T downcastRequest(ControllerRequest request);
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/RequestHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.controller;
+
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ResponseProperties;
+import org.jboss.portal.portlet.test.PageNavigationalState;
+import static org.jboss.portal.portlet.test.controller.PortletController.ControllerRequest;
+import static org.jboss.portal.portlet.test.controller.PortletController.ViewRequest;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class ViewRequestHandler extends RequestHandler<ViewRequest>
+{
+ public ViewRequestHandler(PortletController controller)
+ {
+ super(controller);
+ }
+
+ void processResponse(ViewRequest request, PortletInvocationResponse response) throws IOException, PortletInvokerException
+ {
+ controller.render(request.controllerContext, new ResponseProperties(), new PageNavigationalState());
+ }
+
+ PortletInvocationResponse invoke(ViewRequest controllerRequest) throws PortletInvokerException
+ {
+ return null;
+ }
+
+ ViewRequest downcastRequest(ControllerRequest request)
+ {
+ if (!(request instanceof ViewRequest))
+ {
+ throw new IllegalArgumentException("Request " + request + " cannot be handled by this handler");
+ }
+
+ return (ViewRequest)request;
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/ViewRequestHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-01-31 23:10:24 UTC (rev 9689)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-01-31 23:58:12 UTC (rev 9690)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.simple;
-import org.jboss.portal.portlet.test.PortletController;
-import org.jboss.portal.portlet.test.PortletControllerContextImpl;
+import org.jboss.portal.portlet.test.controller.PortletController;
+import org.jboss.portal.portlet.test.controller.PortletControllerContextImpl;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
16 years, 2 months
JBoss Portal SVN: r9689 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-01-31 18:10:24 -0500 (Thu, 31 Jan 2008)
New Revision: 9689
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
Log:
2.2.1.3. Database Setup adding a bit more content,
rephrasing
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-01-31 18:26:29 UTC (rev 9688)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/installation.xml 2008-01-31 23:10:24 UTC (rev 9689)
@@ -83,33 +83,29 @@
</sect3>
<sect3>
<title>Database Setup</title>
- <para>You will need a database for JBoss Portal to run, you can use any database
- supported by Hibernate.
+ <para>
+ A database is required for JBoss Portal to run. JBoss EAP and JBoss AS include an embedded Hypersonic SQL database that JBoss Portal can use; however, this is only recommended for developer use. The following databases are recommended for production use, and have had test suites run against them: MySQL 4, MySQL 5, Microsoft SQL Server, PostgreSQL 8, Oracle 9, and Oracle 10. JBoss Portal can use any database that is supported by Hibernate.
+ </para>
+ <para>
+ To configure a database to use with JBoss Portal:
+ </para>
<orderedlist>
<listitem>
<para>
- <emphasis role="bold">Create a new Database:</emphasis>
- For example purposes we call this new database
- <emphasis>jbossportal</emphasis>
+ <emphasis role="bold">Create a new Database:</emphasis> this guide assumes that the new database will be called <emphasis>jbossportal</emphasis>.
</para>
</listitem>
<listitem>
<para>
- <emphasis role="bold">Grant access rights for a user to your database:</emphasis>
- You must make sure the user has access to this new DB, as JBoss Portal will need to create the
- tables and modify data within them.
+ <emphasis role="bold">Grant access rights for a user to the <emphasis>jbossportal</emphasis> database:</emphasis> JBoss Portal needs to create tables and modify table data. Grant access rights to a desired user to the <emphasis>jbossportal</emphasis> database. Configure the same username and password in the Datasource descriptor.
</para>
</listitem>
<listitem>
<para>
- <emphasis role="bold">Deploy your JDBC connector:</emphasis>
- You must make available a JDBC connector for JBoss Portal to communicate with your database. The
- connector lib should be placed in
- <filename>JBOSS_INSTALL_DIRECTORY/server/default/lib/*</filename>
+ <emphasis role="bold">Deploy a RDBMS JDBC connector:</emphasis> a RDBMS JDBC connector is required for JBoss Portal to communicate with a database. Copy the connector into the <filename>JBOSS_INSTALL_DIRECTORY/server/default/lib/</filename> directory. For example, a RDBMS JDBC connector for MySQL can be download from <ulink url="http://www.mysql.com/products/connector/j/"></ulink>. For the correct RDMBS JDBC connector, please refer to the database documentation.
</para>
</listitem>
</orderedlist>
- </para>
</sect3>
<sect3>
<title>DataSource Configuration</title>
16 years, 2 months
JBoss Portal SVN: r9688 - modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 13:26:29 -0500 (Thu, 31 Jan 2008)
New Revision: 9688
Modified:
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostApplicationXWWWFormURLEncodedTestCase.java
modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostMultipartFormDataTestCase.java
Log:
synching with jboss unit remote http protocol api changes
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostApplicationXWWWFormURLEncodedTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostApplicationXWWWFormURLEncodedTestCase.java 2008-01-31 14:23:29 UTC (rev 9687)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostApplicationXWWWFormURLEncodedTestCase.java 2008-01-31 18:26:29 UTC (rev 9688)
@@ -26,15 +26,14 @@
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.web.WebRequest;
-import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.web.Body;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import org.jboss.unit.Failure;
import org.jboss.unit.api.Assert;
Modified: modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostMultipartFormDataTestCase.java
===================================================================
--- modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostMultipartFormDataTestCase.java 2008-01-31 14:23:29 UTC (rev 9687)
+++ modules/web/trunk/web/src/test/java/org/jboss/portal/test/web/request/PostMultipartFormDataTestCase.java 2008-01-31 18:26:29 UTC (rev 9688)
@@ -26,17 +26,16 @@
import org.jboss.portal.test.web.TestServlet;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.http.HttpRequest;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.Body;
-import org.jboss.portal.web.IllegalRequestException;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.api.Assert;
import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.http.HttpRequest;
import org.jboss.unit.Failure;
import static org.jboss.unit.api.Assert.*;
16 years, 2 months
JBoss Portal SVN: r9687 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/filter and 3 other directories.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2008-01-31 09:23:29 -0500 (Thu, 31 Jan 2008)
New Revision: 9687
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/filter/FilterMetaData.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/FilterTestEverythingTestCase.java
modules/portlet/trunk/test/src/test/resources/metadata/general/portlet-app_2_0.xml
Log:
use LifeCyclePhase enum instead of a plain string
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java 2008-01-31 14:11:59 UTC (rev 9686)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/LifeCyclePhase.java 2008-01-31 14:23:29 UTC (rev 9687)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet;
+import javax.xml.bind.annotation.XmlEnumValue;
+
/**
* Enumerate the life cycle phase of a Portlet.
*
@@ -30,5 +32,8 @@
*/
public enum LifeCyclePhase
{
- ACTION, EVENT, RENDER, RESOURCE
+ @XmlEnumValue("ACTION_PHASE") ACTION,
+ @XmlEnumValue("EVENT_PHASE") EVENT,
+ @XmlEnumValue("RENDER_PHASE") RENDER,
+ @XmlEnumValue("RESOURCE_PHASE") RESOURCE
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/filter/FilterMetaData.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/filter/FilterMetaData.java 2008-01-31 14:11:59 UTC (rev 9686)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/metadata/filter/FilterMetaData.java 2008-01-31 14:23:29 UTC (rev 9687)
@@ -31,6 +31,7 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.portlet.impl.metadata.PortletMetaDataConstants;
import org.jboss.portal.portlet.impl.metadata.common.InitParamMetaData;
import org.jboss.portal.portlet.impl.metadata.adapter.LocalizedStringAdapter;
@@ -52,7 +53,7 @@
private String filterClass;
/** The filter lifecycle */
- private List<String> lifecycle;
+ private List<LifeCyclePhase> lifecycle;
/** The filter display name */
private LocalizedString displayName;
@@ -85,23 +86,21 @@
}
@XmlElement(name = "lifecycle", required = true)
-// @XmlJavaTypeAdapter(FilterLifeCycleAdapter.class)
-// public List<LifeCycleEnumMetaData> getLifecycle()
- public List<String> getLifecycle()
+ public List<LifeCyclePhase> getLifecycle()
{
return lifecycle;
}
- public void setLifecycle(List<String> lifecycle)
+ public void setLifecycle(List<LifeCyclePhase> lifecycle)
{
this.lifecycle = lifecycle;
}
- public void addLifecycle(String lifecycle)
+ public void addLifecycle(LifeCyclePhase lifecycle)
{
if( this.lifecycle == null)
{
- this.lifecycle = new ArrayList<String>();
+ this.lifecycle = new ArrayList<LifeCyclePhase>();
}
this.lifecycle.add(lifecycle);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java 2008-01-31 14:11:59 UTC (rev 9686)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/metadata/factory/PortletApplicationModelFactory.java 2008-01-31 14:23:29 UTC (rev 9687)
@@ -29,6 +29,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.portlet.TransportGuarantee;
import org.jboss.portal.portlet.impl.metadata.CustomPortletModeMetaData;
import org.jboss.portal.portlet.impl.metadata.CustomWindowStateMetaData;
@@ -750,7 +751,15 @@
}
else if ("lifecycle".equals(localName))
{
- md.addLifecycle(value);
+ String lifeCycle = value.substring(0 , value.length() - "_PHASE".length());
+ try
+ {
+ md.addLifecycle(LifeCyclePhase.valueOf(lifeCycle));
+ }
+ catch(IllegalArgumentException e)
+ {
+ throw new IllegalArgumentException("Invalid value for lifecycle. Valid values are [RENDER_PHASE, RESOURCE_PHASE, ACTION_PHASE, EVENT_PHASE]");
+ }
}
}
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/FilterTestEverythingTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/FilterTestEverythingTestCase.java 2008-01-31 14:11:59 UTC (rev 9686)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/test/metadata/FilterTestEverythingTestCase.java 2008-01-31 14:23:29 UTC (rev 9687)
@@ -24,6 +24,7 @@
import java.util.Locale;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.common.InitParamMetaData;
import org.jboss.portal.portlet.impl.metadata.filter.FilterMetaData;
@@ -68,8 +69,8 @@
assertNotNull(filter);
assertEquals("org.jboss.portal.meta.NoExistingClass", filter.getFilterClass());
assertEquals("testFilter", filter.getFilterName());
- assertEquals("ACTION_PHASE", filter.getLifecycle().get(0));
- assertEquals("RENDER_PHASE", filter.getLifecycle().get(1));
+ assertEquals(LifeCyclePhase.ACTION, filter.getLifecycle().get(0));
+ assertEquals(LifeCyclePhase.RENDER, filter.getLifecycle().get(1));
assertEquals("test", filter.getDescription().getDefaultString());
assertEquals("bla", filter.getDescription().getString(new Locale("de"), false));
@@ -91,7 +92,7 @@
//
FilterMetaData filter2 = md.getFilter("testFilterZwei");
assertEquals("testFilterZwei", filter2.getFilterName());
- assertEquals("ACTION_PHASE", filter2.getLifecycle().get(0));
+ assertEquals(LifeCyclePhase.ACTION, filter2.getLifecycle().get(0));
// Filter mapping
assertTrue(md.getFilterMapping().containsKey("testFilter"));
Modified: modules/portlet/trunk/test/src/test/resources/metadata/general/portlet-app_2_0.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/metadata/general/portlet-app_2_0.xml 2008-01-31 14:11:59 UTC (rev 9686)
+++ modules/portlet/trunk/test/src/test/resources/metadata/general/portlet-app_2_0.xml 2008-01-31 14:23:29 UTC (rev 9687)
@@ -82,7 +82,7 @@
<display-name xml:lang="en">display-name</display-name>
<filter-name>filter-name</filter-name>
<filter-class>filter-class</filter-class>
- <lifecycle>lifecycle</lifecycle>
+ <lifecycle>RENDER_PHASE</lifecycle>
<init-param id="">
<description xml:lang="en">description</description>
<name>name</name>
16 years, 2 months
JBoss Portal SVN: r9686 - in modules/portlet/trunk: portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 09:11:59 -0500 (Thu, 31 Jan 2008)
New Revision: 9686
Removed:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
Log:
- support for next possible portlet modes
- removed ModesInterceptor and WindowStatesInterceptor to simplify
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -1,100 +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.aspects.portlet;
-
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.portlet.info.CapabilitiesInfo;
-import org.jboss.portal.portlet.info.ModeInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.PortletInterceptor;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.container.PortletContainerInvoker;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.common.util.ContentInfo;
-import org.jboss.portal.Mode;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * The ModesInterceptor computes the mode for the request as well as the supported modes.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7226 $
- */
-public class ModesInterceptor extends PortletInterceptor
-{
-
- protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
- {
- if ((invocation.getContext()).getMode() == null)
- {
- throw new InvocationException("No mode has been provided");
- }
-
- // Compute the supported modes.
- Set modes = getModes(invocation);
-
- // Set the modes on the invocation
- invocation.setSupportedModes(modes);
-
- // Continue the invocation
- return invocation.invokeNext();
- }
-
- /** Compute the supported modes for this invocation. */
- protected Set<Mode> getModes(PortletInvocation invocation)
- {
- // Get content type
- ContentInfo si = invocation.getContext().getMarkupInfo();
- String contentType = si.getContentType().toString();
-
- // Get the modes for this content type
- PortletContainer container = (PortletContainer)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PortletContainerInvoker.PORTLET_CONTAINER);
- PortletInfo containerInfo = container.getInfo();
- CapabilitiesInfo capabilities = containerInfo.getCapabilities();
-
- // Add all the modes
- Set<Mode> modes = new HashSet<Mode>();
- for (ModeInfo modeInfo : capabilities.getModes(contentType))
- {
- modes.add(modeInfo.getMode());
- }
-
- // Restrict with what the portal can provide
- Set<Mode> portalModes = invocation.getPortalContext().getModes();
- modes.retainAll(portalModes);
-
- // If user is not logged in then remove the edit mode
- // commenting out for now since it breaks tests
-// AccessMode accessMode = invocation.getInstanceContext().getAccessMode();
-// if (accessMode == AccessMode.READ_ONLY)
-// {
-// modes.remove(Mode.EDIT);
-// }
-
- //
- return modes;
- }
-}
Deleted: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -1,69 +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.aspects.portlet;
-
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.portlet.invocation.PortletInterceptor;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.WindowState;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * The WindowStatesInterceptor computes the window state for the request as well as the supported window states.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 7028 $
- */
-public class WindowStatesInterceptor extends PortletInterceptor
-{
-
- protected Object invoke(PortletInvocation invocation) throws Exception, InvocationException
- {
- if (invocation.getContext().getWindowState() == null)
- {
- throw new InvocationException("No window state has been provided");
- }
-
- // Compute the supported window states
- Set windowStates = getWindowStates(invocation);
-
- //
- invocation.setSupportedWindowStates(windowStates);
-
- // Continue the invocation
- return invocation.invokeNext();
- }
-
- /**
- * Compute the supported window states for this invocation.
- *
- * @param invocation the invocation
- * @return the set of window states
- */
- protected Set<WindowState> getWindowStates(PortletInvocation invocation)
- {
- return new HashSet<WindowState>(invocation.getPortalContext().getWindowStates());
- }
-}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -27,7 +27,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MultiValuedPropertyMap;
import org.jboss.portal.common.util.SimpleMultiValuedPropertyMap;
-import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.ContentInfo;
import org.jboss.portal.portlet.container.PortletContainerInvoker;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
@@ -45,6 +45,9 @@
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.portlet.spi.ClientContext;
import org.jboss.portal.portlet.state.PropertyContext;
+import org.jboss.portal.portlet.info.CapabilitiesInfo;
+import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.Mode;
import javax.portlet.PortalContext;
import javax.portlet.PortletMode;
@@ -63,6 +66,7 @@
import java.util.Map;
import java.util.Set;
import java.util.List;
+import java.util.HashSet;
/**
* PortletRequest implemention. The parameter implementation is left to subclasses that can implement it differently.
@@ -100,6 +104,12 @@
/** . */
protected final PortletRequestParameterMap requestParameterMap;
+ /** . */
+ protected final Set<Mode> supportedModes;
+
+ /** . */
+ protected final Set<org.jboss.portal.WindowState> supportedWindowStates;
+
public PortletRequestImpl(PortletInvocation invocation)
{
PortletContainerImpl container = (PortletContainerImpl)invocation.getAttribute(PortletInvocation.INVOCATION_SCOPE, PortletContainerInvoker.PORTLET_CONTAINER);
@@ -125,6 +135,8 @@
this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator, mode);
this.navigationInfo = navigationInfo;
this.requestParameterMap = PortletRequestParameterMap.create(navigationInfo, invocation.getContext());
+ this.supportedModes = buildSupportedModes();
+ this.supportedWindowStates = buildSupportedWindowState();
}
// PLT.11.1.1
@@ -346,7 +358,7 @@
}
else
{
- return invocation.getSupportedModes().contains(org.jboss.portal.Mode.create(portletMode.toString()));
+ return supportedModes.contains(org.jboss.portal.Mode.create(portletMode.toString()));
}
}
@@ -354,7 +366,7 @@
public boolean isWindowStateAllowed(WindowState windowState)
{
- return invocation.getSupportedWindowStates().contains(org.jboss.portal.WindowState.create(windowState.toString()));
+ return supportedWindowStates.contains(org.jboss.portal.WindowState.create(windowState.toString()));
}
//
@@ -520,4 +532,39 @@
protected void initProperties(MultiValuedPropertyMap<String> properties)
{
}
+
+ /**
+ * Build the initial set of supported modes.
+ *
+ * @return the set of portlet modes
+ */
+ private Set<Mode> buildSupportedModes()
+ {
+ // Get content type
+ ContentInfo si = invocation.getContext().getMarkupInfo();
+ String contentType = si.getContentType().toString();
+
+ // Get the modes for this content type
+ CapabilitiesInfo capabilities = container.getInfo().getCapabilities();
+
+ // Add all the modes
+ Set<Mode> modes = new HashSet<Mode>();
+ for (ModeInfo modeInfo : capabilities.getModes(contentType))
+ {
+ modes.add(modeInfo.getMode());
+ }
+
+ //
+ return modes;
+ }
+
+ /**
+ * Build the initial set of supported modes.
+ *
+ * @return the set of portlet modes
+ */
+ private Set<org.jboss.portal.WindowState> buildSupportedWindowState()
+ {
+ return new HashSet<org.jboss.portal.WindowState>(invocation.getPortalContext().getWindowStates());
+ }
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -22,12 +22,16 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.api;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.Mode;
import javax.portlet.RenderResponse;
import javax.portlet.PortletMode;
import java.util.Collection;
+import java.util.Set;
+import java.util.LinkedHashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -41,6 +45,9 @@
super(invocation, preq);
}
+ /** . */
+ private Set<Mode> nextModes;
+
public void setTitle(String s)
{
fragment.setTitle(s);
@@ -48,6 +55,47 @@
public void setNextPossiblePortletModes(Collection<PortletMode> portletModes)
{
- throw new NotYetImplemented();
+ if (portletModes != null && portletModes.size() > 0)
+ {
+ if (this.nextModes == null)
+ {
+ nextModes = new LinkedHashSet<Mode>(portletModes.size());
+ }
+ else
+ {
+ nextModes.clear();
+ }
+
+ //
+ for (PortletMode portletMode : portletModes)
+ {
+ if (portletMode != null)
+ {
+ Mode mode = Mode.create(portletMode.toString());
+
+ //
+ if (preq.supportedModes.contains(mode))
+ {
+ nextModes.add(mode);
+ }
+ }
+ else
+ {
+ // Log
+ }
+ }
+ }
}
+
+ public PortletInvocationResponse getResponse()
+ {
+ PortletInvocationResponse response = super.getResponse();
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ fragment.setNextModes(nextModes != null ? nextModes : preq.supportedModes);
+ }
+ return response;
+ }
+
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -85,12 +85,6 @@
/** The window context. */
protected WindowContext windowContext;
- /** The window states this portlet can accept. */
- protected Set supportedWindowStates;
-
- /** The modes this portlet can accept. */
- protected Set supportedModes;
-
/** The dispatched request. */
protected HttpServletRequest dreq;
@@ -132,26 +126,6 @@
this.target = target;
}
- public Set getSupportedWindowStates()
- {
- return supportedWindowStates;
- }
-
- public void setSupportedWindowStates(Set supportedWindowStates)
- {
- this.supportedWindowStates = supportedWindowStates;
- }
-
- public Set getSupportedModes()
- {
- return supportedModes;
- }
-
- public void setSupportedModes(Set supportedModes)
- {
- this.supportedModes = supportedModes;
- }
-
/**
* Returns the dispatched http servlet request.
*
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/response/FragmentResponse.java 2008-01-31 14:11:59 UTC (rev 9686)
@@ -24,11 +24,13 @@
import org.jboss.portal.portlet.cache.CacheControl;
import org.jboss.portal.portlet.impl.jsr168.ContentBuffer;
+import org.jboss.portal.Mode;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Set;
/**
* Data produced.
@@ -60,12 +62,16 @@
/** . */
private CacheControl cacheControl;
+ /** . */
+ private Set<Mode> nextModes;
+
public FragmentResponse()
{
this.buffer = new ContentBuffer();
this.title = null;
this.cacheControl = null;
this.properties = null;
+ this.nextModes = null;
}
public ResponseProperties getProperties()
@@ -184,4 +190,14 @@
{
return buffer;
}
+
+ public Set<Mode> getNextModes()
+ {
+ return nextModes;
+ }
+
+ public void setNextModes(Set<Mode> nextModes)
+ {
+ this.nextModes = nextModes;
+ }
}
Modified: modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/test/src/test/resources/portlet-test-war/WEB-INF/jboss-beans.xml 2008-01-31 14:11:59 UTC (rev 9686)
@@ -82,8 +82,6 @@
class="org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor">
<property name="servletContainerFactory"><inject bean="ServletContainerFactory"/></property>
</bean>
- <bean name="WindowStatesInterceptor" class="org.jboss.portal.portlet.aspects.portlet.WindowStatesInterceptor"/>
- <bean name="ModesInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ModesInterceptor"/>
<bean name="ProducerCacheInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor"/>
<bean name="ContainerStackFactory" class="org.jboss.portal.portlet.test.InterceptorStackFactoryImpl">
<property name="interceptors">
@@ -91,8 +89,6 @@
<inject bean="ValveInterceptor"/>
<inject bean="SecureTransportInterceptor"/>
<inject bean="ContextDispatcherInterceptor"/>
- <inject bean="WindowStatesInterceptor"/>
- <inject bean="ModesInterceptor"/>
<inject bean="ProducerCacheInterceptor"/>
</array>
</property>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-01-31 13:38:03 UTC (rev 9685)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/jboss-beans.xml 2008-01-31 14:11:59 UTC (rev 9686)
@@ -70,8 +70,6 @@
class="org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor">
<property name="servletContainerFactory"><inject bean="ServletContainerFactory"/></property>
</bean>
- <bean name="WindowStatesInterceptor" class="org.jboss.portal.portlet.aspects.portlet.WindowStatesInterceptor"/>
- <bean name="ModesInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ModesInterceptor"/>
<bean name="ProducerCacheInterceptor" class="org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor"/>
<bean name="ContainerStackFactory" class="org.jboss.portal.portlet.test.InterceptorStackFactoryImpl">
<property name="interceptors">
@@ -79,8 +77,6 @@
<inject bean="ValveInterceptor"/>
<inject bean="SecureTransportInterceptor"/>
<inject bean="ContextDispatcherInterceptor"/>
- <inject bean="WindowStatesInterceptor"/>
- <inject bean="ModesInterceptor"/>
<inject bean="ProducerCacheInterceptor"/>
</array>
</property>
16 years, 2 months
JBoss Portal SVN: r9685 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 08:38:03 -0500 (Thu, 31 Jan 2008)
New Revision: 9685
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml
Log:
- implemented request life cycle attribute
- added test case for request life cycle attribute
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java 2008-01-31 13:17:54 UTC (rev 9684)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/APIConstants.java 2008-01-31 13:38:03 UTC (rev 9685)
@@ -28,33 +28,24 @@
*/
public interface APIConstants
{
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_TITLE = "javax.portlet.title";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_SHORT_TITLE = "javax.portlet.short-title";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_KEYWORDS = "javax.portlet.keywords";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_CONFIG = "javax.portlet.config";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_REQUEST = "javax.portlet.request";
- /**
- *
- */
+ /** . */
String JAVAX_PORTLET_RESPONSE = "javax.portlet.response";
+
+ /** . */
+ String JAVAX_PORTLET_LIFECYCLE_PHASE = "javax.portlet.lifecycle_phase";
}
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-31 13:17:54 UTC (rev 9684)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-31 13:38:03 UTC (rev 9685)
@@ -417,6 +417,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "ACTION_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
portlet.processAction(req, resp);
}
@@ -425,6 +426,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
@@ -442,6 +444,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "RENDER_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
portlet.render(req, resp);
}
@@ -450,6 +453,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
return resp.getResponse();
@@ -470,6 +474,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, ereq);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, eresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "EVENT_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
eventPortlet.processEvent(ereq, eresp);
}
@@ -478,6 +483,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
return eresp.getResponse();
@@ -498,6 +504,7 @@
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE, "RESOURCE_SERVING_PHASE");
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION, invocation);
eventPortlet.serveResource(req, resp);
}
@@ -506,6 +513,7 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_LIFECYCLE_PHASE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/LifeCyclePhaseRequestAttributeTestCase.java 2008-01-31 13:38:03 UTC (rev 9685)
@@ -0,0 +1,107 @@
+/******************************************************************************
+ * 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.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.actions.PortletActionTestAction;
+import org.jboss.portal.unit.actions.PortletEventTestAction;
+import org.jboss.portal.unit.actions.PortletResourceTestAction;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+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.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(Assertion.JSR286_90)
+public class LifeCyclePhaseRequestAttributeTestCase
+{
+
+ public LifeCyclePhaseRequestAttributeTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ return new InvokeGetResponse(response.createActionURL().toString());
+ }
+ });
+ seq.bindAction(1, UTP6.ACTION_JOIN_POINT, new PortletActionTestAction()
+ {
+ protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("ACTION_PHASE", request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ response.setEvent("Event", null);
+ }
+ });
+ seq.bindAction(1, UTP6.EVENT_JOIN_POINT, new PortletEventTestAction()
+ {
+ protected void run(Portlet portlet, EventRequest request, EventResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("EVENT_PHASE", request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+ }
+ });
+ seq.bindAction(1, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("RENDER_PHASE", request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ return new InvokeGetResponse(response.createResourceURL().toString());
+ }
+ });
+ seq.bindAction(2, UTP6.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ assertEquals("RESOURCE_SERVING_PHASE", request.getAttribute(PortletRequest.LIFECYCLE_PHASE));
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31 13:17:54 UTC (rev 9684)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31 13:38:03 UTC (rev 9685)
@@ -27,7 +27,7 @@
import org.jboss.portal.unit.Assertion;
import org.jboss.portal.unit.actions.PortletRenderTestAction;
import org.jboss.portal.unit.annotations.TestCase;
-import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.response.EndTestResponse;
import static org.jboss.unit.api.Assert.*;
@@ -50,7 +50,7 @@
public WindowIDTestCase(PortletTestCase seq)
{
- seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ seq.bindAction(0, UTP6.RENDER_JOIN_POINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
{
Modified: modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml 2008-01-31 13:17:54 UTC (rev 9684)
+++ modules/portlet/trunk/test/src/test/resources/jsr286/tck/portletrequests-war/WEB-INF/portlet.xml 2008-01-31 13:38:03 UTC (rev 9685)
@@ -82,6 +82,20 @@
<supported-public-render-parameter>daa</supported-public-render-parameter>
</portlet>
+ <portlet>
+ <portlet-name>UniversalTestPortletF</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <supported-processing-event>
+ <name>Event</name>
+ </supported-processing-event>
+ <supported-publishing-event>
+ <name>Event</name>
+ </supported-publishing-event>
+ </portlet>
+
<event-definition>
<name>Event</name>
</event-definition>
16 years, 2 months
JBoss Portal SVN: r9684 - in modules/portlet/trunk/portlet/src: main/java/org/jboss/portal/portlet/impl/jsr168/api and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 08:17:54 -0500 (Thu, 31 Jan 2008)
New Revision: 9684
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
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/ContainerPortletInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
Log:
- implemented PortletRequest.getWindowID()
- added test case for window id
Added: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java (rev 0)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerFilterInfo.java 2008-01-31 13:17:54 UTC (rev 9684)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * 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.portlet.LifeCyclePhase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerFilterInfo
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String className;
+
+ /** . */
+ private final LifeCyclePhase lifeCycle;
+
+ /** . */
+ private final LocalizedString displayName;
+
+ /** . */
+ private final LocalizedString description;
+
+ /** . */
+ private final Map<String, String> parameters;
+
+ public ContainerFilterInfo(
+ String name,
+ String className,
+ LifeCyclePhase lifeCycle,
+ LocalizedString displayName,
+ LocalizedString description,
+ Map<String, String> parameters)
+ {
+ this.name = name;
+ this.className = className;
+ this.lifeCycle = lifeCycle;
+ this.displayName = displayName;
+ this.description = description;
+ this.parameters = parameters;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public LifeCyclePhase getLifeCycle()
+ {
+ return lifeCycle;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public Map<String, String> getParameters()
+ {
+ return parameters;
+ }
+}
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-01-31 11:36:26 UTC (rev 9683)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-01-31 13:17:54 UTC (rev 9684)
@@ -38,7 +38,9 @@
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.filter.FilterMetaData;
import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.LifeCyclePhase;
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.common.value.StringValue;
@@ -60,6 +62,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
+import java.util.Collections;
import java.net.URI;
import java.net.URISyntaxException;
@@ -292,12 +295,39 @@
//
publicParameters.put(parameter.getId(), parameter);
}
+
+ //
+// for (FilterMetaData filterMD : tmp.getFilterCollection())
+// {
+// ContainerFilterInfo filter = build(filterMD);
+// }
}
//
return new ContainerPortletApplicationInfo(defaultNamespace);
}
+ private ContainerFilterInfo build(FilterMetaData filterMD)
+ {
+ Map<String, String> initParameters = new HashMap<String, String>();
+ for (InitParamMetaData initParamMD : filterMD.getInitParams())
+ {
+ initParameters.put(initParamMD.getName(), initParamMD.getValue());
+ }
+
+ LifeCyclePhase lifeCycle;
+
+ //
+ return new ContainerFilterInfo(
+ filterMD.getFilterName(),
+ filterMD.getFilterClass(),
+ null,
+ filterMD.getDisplayName(),
+ filterMD.getDescription(),
+ Collections.unmodifiableMap(initParameters)
+ );
+ }
+
private ContainerParameterInfo build(PublicRenderParameterMetaData parameterMD)
{
QName name = getName(parameterMD.getQname(), parameterMD.getName());
@@ -357,6 +387,13 @@
ContainerSessionInfo containerSession = buildContainerSession(portletMD);
//
+ Map<String, String> initParameters = new HashMap<String, String>();
+ for (InitParamMetaData initParamMD : portletMD.getInitParams())
+ {
+ initParameters.put(initParamMD.getName(), initParamMD.getValue());
+ }
+
+ //
ContainerPortletInfo containerPortletInfo;
if (portletApplicationMD instanceof PortletApplication20MetaData)
{
@@ -375,6 +412,7 @@
containerNavigation,
portletMD.getPortletName(),
portletMD.getPortletClass(),
+ Collections.unmodifiableMap(initParameters),
false,
context.getBundleManager(portletMD)
);
@@ -390,18 +428,13 @@
containerSession,
portletMD.getPortletName(),
portletMD.getPortletClass(),
+ Collections.unmodifiableMap(initParameters),
false,
context.getBundleManager(portletMD)
);
}
//
- for (InitParamMetaData initParamMD : portletMD.getInitParams())
- {
- containerPortletInfo.addInitParameter(initParamMD.getName(), initParamMD.getValue());
- }
-
- //
return containerPortletInfo;
}
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-31 11:36:26 UTC (rev 9683)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-01-31 13:17:54 UTC (rev 9684)
@@ -87,6 +87,7 @@
ContainerSessionInfo session,
String name,
String className,
+ Map<String, String> initParameters,
Boolean remotable,
ResourceBundleManager bundleManager)
{
@@ -100,7 +101,7 @@
this.navigation = new ContainerNavigationInfo();
this.name = name;
this.className = className;
- this.initParameters = new HashMap<String, String>();
+ this.initParameters = initParameters;
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -116,6 +117,7 @@
ContainerNavigationInfo navigation,
String name,
String className,
+ Map<String, String> initParameters,
Boolean remotable,
ResourceBundleManager bundleManager)
{
@@ -129,7 +131,7 @@
this.navigation = navigation;
this.name = name;
this.className = className;
- this.initParameters = new HashMap<String, String>();
+ this.initParameters = initParameters;
this.remotable = remotable;
this.bundleManager = bundleManager;
}
@@ -149,11 +151,6 @@
return className;
}
- public void addInitParameter(String parameterName, String parameterValue)
- {
- initParameters.put(parameterName, parameterValue);
- }
-
public Set<String> getInitParameterNames()
{
return initParameters.keySet();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31 11:36:26 UTC (rev 9683)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-31 13:17:54 UTC (rev 9684)
@@ -453,7 +453,7 @@
public String getWindowID()
{
- throw new NotYetImplemented();
+ return windowContext.getId();
}
public Cookie[] getCookies()
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/portletrequests/WindowIDTestCase.java 2008-01-31 13:17:54 UTC (rev 9684)
@@ -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.test.portlet.jsr286.tck.portletrequests;
+
+import org.jboss.portal.unit.PortletTestCase;
+import org.jboss.portal.unit.PortletTestContext;
+import org.jboss.portal.unit.Assertion;
+import org.jboss.portal.unit.actions.PortletRenderTestAction;
+import org.jboss.portal.unit.annotations.TestCase;
+import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.EndTestResponse;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+(a)TestCase(Assertion.JSR286_97)
+public class WindowIDTestCase
+{
+
+ public WindowIDTestCase(PortletTestCase seq)
+ {
+ seq.bindAction(0, UTP5.RENDER_JOIN_POINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
+ {
+ String windowID = request.getWindowID();
+ WindowIDRetriever retriever = new WindowIDRetriever();
+ request.getPortletSession().setAttribute("retriever", retriever);
+ assertEquals(retriever.getWindowID(), windowID);
+ return new EndTestResponse();
+ }
+ });
+ }
+
+ public static class WindowIDRetriever implements HttpSessionBindingListener
+ {
+
+ /** . */
+ private String windowID;
+
+ public void valueBound(HttpSessionBindingEvent event)
+ {
+ String name = event.getName();
+ windowID = name.substring("javax.portlet.p.".length(), name.indexOf('?'));
+ }
+
+ public void valueUnbound(HttpSessionBindingEvent event)
+ {
+ }
+
+ public String getWindowID()
+ {
+ return windowID;
+ }
+ }
+}
16 years, 2 months
JBoss Portal SVN: r9683 - modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2008-01-31 06:36:26 -0500 (Thu, 31 Jan 2008)
New Revision: 9683
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
Log:
more, more and more....
Modified: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-31 11:18:50 UTC (rev 9682)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/unit/Assertion.java 2008-01-31 11:36:26 UTC (rev 9683)
@@ -26,6 +26,7 @@
* Define TCK assertions.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
public enum Assertion
@@ -60,17 +61,17 @@
" portal/portlet-container to redirect the user to a specific URL. If the portlet issues a redirection, when the" +
" processAction method concludes, the portal/portlet-container must send the redirection back to the user agent"),
- JSR168_17(new TCK(17), "A PortletException signals that an error has occurred during the processing" +
+ JSR168_17(new TCK(17), Status.disabled("spec?"), "A PortletException signals that an error has occurred during the processing" +
" of the request and that the portlet container should take appropriate measures to clean up the request. If a portlet" +
" throws an exception in the processAction method, all operations on the ActionResponse must be ignored and the render" +
- " method must not be invoked within the current client request", Status.disabled("spec?")),
+ " method must not be invoked within the current client request"),
- JSR168_18(new TCK(18), "If a permanent unavailability is indicated by the UnavailableException, the" +
+ JSR168_18(new TCK(18), Status.disabled("spec?"), "If a permanent unavailability is indicated by the UnavailableException, the" +
" portlet container must remove the portlet from service immediately, call the portlet�s destroy method, and release" +
- " the portlet object.", Status.disabled("spec?")),
+ " the portlet object."),
- JSR168_19(new TCK(19), "A RuntimeException thrown during the request handling must be handled as a" +
- " PortletException", Status.disabled("spec?")),
+ JSR168_19(new TCK(19), Status.disabled("spec?"), "A RuntimeException thrown during the request handling must be handled as a" +
+ " PortletException"),
JSR168_24(new TCK(24), ""),
@@ -84,9 +85,9 @@
" objects using the setParameter and setParameters methods. A call to any of the setParameter methods must replace" +
" any parameter with the same name previously set."),
- JSR168_30(new TCK(30), "", Status.jbossUntestable("why?")),
+ JSR168_30(new TCK(30), Status.jbossUntestable("why?"), ""),
- JSR168_31(new TCK(31), "", Status.jbossUntestable("why?")),
+ JSR168_31(new TCK(31), Status.jbossUntestable("why?"), ""),
JSR168_29(new TCK(29), "All the parameters a portlet adds to a PortletURL object must be made" +
" available to the portlet as request parameters"),
@@ -107,16 +108,16 @@
" requests to the doView, doEdit or doHelp method depending on the portlet mode indicated in the request using the" +
" doDispatch method"),
- JSR168_33(new TCK(33), "", Status.duplicate(JSR168_36, "")),
+ JSR168_33(new TCK(33), Status.duplicate(JSR168_36, ""), ""),
- JSR168_37(new TCK(37), "", Status.duplicate(JSR168_36, "RequestDispatchingDependingOnModePortlet as VIEW mode isn't specified in descriptor")),
+ JSR168_37(new TCK(37), Status.duplicate(JSR168_36, "RequestDispatchingDependingOnModePortlet as VIEW mode isn't specified in descriptor"), ""),
- JSR168_38(new TCK(38), "The portlet must not be invoked in a portlet mode that has not been" +
- " declared as supported for a given markup type", Status.disabled("spec?")),
+ JSR168_38(new TCK(38), Status.disabled("spec?"), "The portlet must not be invoked in a portlet mode that has not been" +
+ " declared as supported for a given markup type"),
- JSR168_40(new TCK(40), "If a custom window state defined in the deployment descriptor is not" +
- " mapped to a custom window state provided by the portal, portlets must not be invoked in that window state.",
- Status.disabled("PortletURL.setWindowState throws an exception because it is not mapped")),
+ JSR168_40(new TCK(40), Status.disabled("PortletURL.setWindowState throws an exception because it is not mapped"), "If a custom window state defined in the deployment descriptor is not" +
+ " mapped to a custom window state provided by the portal, portlets must not be invoked in that window state."
+ ),
JSR168_43(new TCK(43), "The initialization parameters accessible through the PortletContext must" +
" be the same that are accessible through the ServletContext of the portlet application."),
@@ -132,11 +133,11 @@
" ServletContext handles. It must be accessible as a context attribute using the same constant defined in the" +
" Servlet Specification 2.3 SVR 3 Servlet Context Chapter, javax.servlet.context.tempdir."),
- JSR168_47(new TCK(47), "", Status.postponed("spec?")),
+ JSR168_47(new TCK(47), Status.postponed("spec?"), ""),
- JSR168_48(new TCK(48), "", Status.postponed("spec?")),
+ JSR168_48(new TCK(48), Status.postponed("spec?"), ""),
- JSR168_49(new TCK(49), "", Status.postponed("spec?")),
+ JSR168_49(new TCK(49), Status.postponed("spec?"), ""),
JSR168_50(new TCK(50), "The portlet-container must not propagate parameters received in an action" +
" request to subsequent render requests of the portlet."),
@@ -149,7 +150,7 @@
" part of the same client request, the parameters received with render request must be the render parameters set" +
" during the action request."),
- JSR168_53(new TCK(53), "", Status.postponed("spec?")),
+ JSR168_53(new TCK(53), Status.postponed("spec?"), ""),
JSR168_54(new TCK(54), "A portlet must not see any parameter targeted to other portlets."),
@@ -160,7 +161,7 @@
JSR168_56(new TCK(56), "If there is a single parameter value associated with a parameter name the" +
" method returns must return an array of size one containing the parameter value"),
- JSR168_57(new TCK(57), "", Status.specUntestable("")),
+ JSR168_57(new TCK(57), Status.specUntestable(""), ""),
JSR168_58(new TCK(58), "The context path of a request is exposed via the request object. The" +
" context path is the path prefix associated with the deployed portlet application. If the portlet application is" +
@@ -178,14 +179,14 @@
" supports in order of preference. The first element of the enumeration must be the same content type returned by" +
" the getResponseContentType method."),
- JSR168_62(new TCK(62), "", Status.jbossUntestable("PORTAL DOESN'T SUPPORT ADDITIONAL CONTENT TYPES")),
+ JSR168_62(new TCK(62), Status.jbossUntestable("PORTAL DOESN'T SUPPORT ADDITIONAL CONTENT TYPES"), ""),
JSR168_63(new TCK(63), "Only one of the two methods, getPortletInputStream or getReader, can be" +
" used during an action request. If the input stream is obtained, a call to the getReader must throw an" +
" IllegalStateException. Similarly, if the reader is obtained, a call to the getPortletInputStream must throw an" +
" IllegalStateException."),
- JSR168_64(new TCK(64), "", Status.postponed("")),
+ JSR168_64(new TCK(64), Status.postponed(""), ""),
JSR168_65(new TCK(65), "The sendRedirect method instructs the portal/portlet-container to set the" +
" appropriate headers and content body to redirect the user to a different URL. A fully qualified URL or a full path" +
@@ -209,10 +210,10 @@
JSR168_70(new TCK(70), "If the exception is caught by the portlet, the redirection must be" +
" executed."),
- JSR168_71(new TCK(71), "If the setPortletMode or setWindowState methods are called after the" +
+ JSR168_71(new TCK(71), Status.disabled("This is disabled as after propagating IllegalStateException to PortletContainer" +
+ " '500' code is returned which doesn't allow us to end test properly"), "If the setPortletMode or setWindowState methods are called after the" +
" sendRedirect method has been called an IllegalStateException must be thrown. (...) If the exception is propagated" +
- " back to the portlet-container, the redirection must not be executed.", Status.disabled("This is disabled as after propagating IllegalStateException to PortletContainer" +
- " '500' code is returned which doesn't allow us to end test properly")),
+ " back to the portlet-container, the redirection must not be executed."),
JSR168_72(new TCK(72), "Using the setRenderParameter and setRenderParameters methods of the" +
" ActionResponse interface portlets may set render parameters during an action request. A call to any of the" +
@@ -243,21 +244,21 @@
" the Writer of the RenderResponse object. A portlet must use only one of these objects. The portlet container must" +
" throw an IllegalStateException if a portlet attempts to use both."),
- JSR168_80(new TCK(80), "The getBufferSize method returns the size of the underlying buffer being" +
- " used. If no buffering is being used, this method must return the int value of 0 (zero)", Status.disabled("no buffering is implemented yet")),
+ JSR168_80(new TCK(80), Status.disabled("no buffering is implemented yet"), "The getBufferSize method returns the size of the underlying buffer being" +
+ " used. If no buffering is being used, this method must return the int value of 0 (zero)"),
- JSR168_81(new TCK(81), "The portlet can request a preferred buffer size by using the" +
+ JSR168_81(new TCK(81), Status.disabled("no buffering is implemented yet"), "The portlet can request a preferred buffer size by using the" +
" setBufferSize method. The buffer assigned is not required to be the size requested by the portlet, but must be at" +
- " least as large as the size requested.", Status.disabled("no buffering is implemented yet")),
+ " least as large as the size requested."),
- JSR168_82(new TCK(82), "", Status.postponed("")),
+ JSR168_82(new TCK(82), Status.postponed(""), ""),
- JSR168_83(new TCK(83), "If the response is committed and the reset or resetBuffer method is" +
- " called, an IllegalStateException must be thrown.", Status.disabled("no buffering is implemented yet")),
+ JSR168_83(new TCK(83), Status.disabled("no buffering is implemented yet"), "If the response is committed and the reset or resetBuffer method is" +
+ " called, an IllegalStateException must be thrown."),
- JSR168_84(new TCK(84), "", Status.postponed("")),
+ JSR168_84(new TCK(84), Status.postponed(""), ""),
- JSR168_85(new TCK(85), "", Status.postponed("")),
+ JSR168_85(new TCK(85), Status.postponed(""), ""),
JSR168_86(new TCK(86), "The getNamespace method must provide the portlet with a mechanism that" +
" ensures the uniqueness of the returned string in the whole portal page"),
@@ -282,9 +283,9 @@
JSR168_93(new TCK(93), "If a preference attribute is read only, the setValue, setValues and reset" +
" methods must throw a ReadOnlyException when the portlet is in any of the standard modes"),
- JSR168_94(new TCK(94), "", Status.disabled("Tested in every over case in this chapter... DONE")),
+ JSR168_94(new TCK(94), Status.disabled("Tested in every over case in this chapter... DONE"), ""),
- JSR168_95(new TCK(95), "", Status.postponed("why?")),
+ JSR168_95(new TCK(95), Status.postponed("why?"), ""),
JSR168_96(new TCK(96), "All changes made to PortletPreferences object not followed by a call to" +
" the store method must be discarded when the portlet finishes the 20 processAction method."),
@@ -292,7 +293,7 @@
JSR168_97(new TCK(97), "If the store method is invoked within the scope of a render method" +
" invocation, it must throw an IllegalStateException."),
- JSR168_98(new TCK(98), "", Status.postponed("why?")),
+ JSR168_98(new TCK(98), Status.postponed("why?"), ""),
JSR168_99(new TCK(99), "If a preference attribute definition does not contain the read-only" +
" element set to true, the preference attribute is modifiable when the portlet is processing an action request in" +
@@ -305,7 +306,7 @@
JSR168_101(new TCK(101), "If a portlet definition includes a validator, the portlet container must" +
" create a single validator instance per portlet definition. (according to spec: Testable=false ;)"),
- JSR168_102(new TCK(102), "", Status.specUntestable("")),
+ JSR168_102(new TCK(102), Status.specUntestable(""), ""),
JSR168_103(new TCK(103), "When a validator is associated with the preferences of a portlet" +
" definition, the store method of the PortletPreferences implementation must invoke the validate method of the" +
@@ -357,7 +358,7 @@
JSR168_119(new TCK(119), "The variant of these methods that does not receive a scope must be" +
" treated as PORTLET_SCOPE."),
- JSR168_120(new TCK(120), "", Status.jbossUntestable("why?")),
+ JSR168_120(new TCK(120), Status.jbossUntestable("why?"), ""),
JSR168_121(new TCK(121), "The getRequestDispatcher method takes a String argument describing a" +
" path within the scope of the PortletContext of a portlet application. This path must begin with a �/� and it is" +
@@ -430,34 +431,68 @@
JSR168_1000(new TCK(1000), "todo ???"),
// PLT.2 Overview
- JSR286_1(new TCK(1), "", ""),
+ JSR286_1(new TCK(1), Status.specUntestable(""), "PLT.2.5", "Portlet V2.0 containers must support deploying JSR 168 portlets and the JSR 168 deployment descriptor"),
// PLT.5 The Portlet Interface and Additional Life
- JSR286_2(new TCK(2), "", ""),
- JSR286_3(new TCK(3), "", ""),
- JSR286_4(new TCK(4), "", ""),
- JSR286_5(new TCK(5), "", ""),
- JSR286_6(new TCK(6), "", ""),
- JSR286_7(new TCK(7), "", ""),
- JSR286_8(new TCK(8), "", ""),
- JSR286_9(new TCK(9), "", ""),
- JSR286_10(new TCK(10), "", ""),
- JSR286_11(new TCK(11), "", ""),
- JSR286_12(new TCK(12), "", ""),
- JSR286_13(new TCK(13), "", ""),
- JSR286_14(new TCK(14), "", ""),
- JSR286_15(new TCK(15), "", ""),
- JSR286_16(new TCK(16), "", ""),
- JSR286_17(new TCK(17), "", ""),
- JSR286_18(new TCK(18), "", ""),
- JSR286_19(new TCK(19), "", ""),
- JSR286_20(new TCK(20), "", ""),
- JSR286_21(new TCK(21), "", ""),
- JSR286_22(new TCK(22), "", ""),
- JSR286_23(new TCK(23), "", ""),
- JSR286_24(new TCK(24), "", ""),
- JSR286_25(new TCK(25), "", ""),
+ JSR286_2(new TCK(2), Status.specUntestable(""), "PLT.5.1", "For a portlet, not hosted in a distributed environment " +
+ "(the default), the portlet container must instantiate and use only one portlet object per portlet definition"),
+ JSR286_3(new TCK(3), Status.specUntestable(""), "PLT.5.1", "In the case where a portlet is deployed as part of a" +
+ " portlet application marked as distributable, in the web.xml deployment descriptor, a portlet container may " +
+ "instantiate only one portlet object per portlet definition -in the deployment descriptor- per virtual machine (VM)."),
+ JSR286_4(new TCK(4), "PLT.5.2.1", "The portlet container must load the portlet class using the same ClassLoader " +
+ "the servlet container uses for the web application part of the portlet application."),
+ JSR286_5(new TCK(5), "PLT.5.2.2", "After the portlet object is instantiated, the portlet container must initialize " +
+ "the portlet before invoking it to handle requests."),
+ JSR286_6(new TCK(6), "PLT.5.2.2.1", "During initialization, the portlet object may throw an UnavailableException " +
+ "or a PortletException. In this case, the portlet container must not place the portlet object into active " +
+ "service and it must release the portlet object."),
+ JSR286_7(new TCK(7), "PLT.5.2.2.1", "The destroy method must not be called because the initialization is considered " +
+ "unsuccessful."),
+ JSR286_8(new TCK(8), "PLT.5.2.2.1", "The portlet container may reattempt to instantiate and initialize the portlets " +
+ "at any time after a failure. The exception to this rule is when an UnavailableException indicates a minimum time " +
+ "of unavailability. When this happens the portlet container must wait for 30 the specified time to pass before " +
+ "creating and initializing a new portlet object."),
+ JSR286_9(new TCK(9), "PLT.5.2.2.1", "A RuntimeException thrown during initialization must be handled as a " +
+ "PortletException."),
+ JSR286_10(new TCK(10), Status.specUntestable(""), "PLT.5.2.3", "Once the destroy method is called on a portlet " +
+ "object, the portlet container must not route any requests to that portlet object."),
+ JSR286_11(new TCK(11), Status.specUntestable(""), "PLT.5.2.3", "If the portlet container needs to enable the " +
+ "portlet again, it must do so with a new portlet object, which is a new instance of the portlet’s class."),
+ JSR286_12(new TCK(12), Status.specUntestable(""), "PLT.5.2.3", "If the portlet object throws a RuntimeException " +
+ "within the execution of the destroy method the portlet container must consider the portlet object successfully " +
+ "destroyed."),
+ JSR286_13(new TCK(13), Status.specUntestable(""), "PLT.5.2.3", "After the destroy method completes, the portlet " +
+ "container must release the portlet object so that it is eligible for garbage collection."),
+ JSR286_14(new TCK(14), "PLT.5.4", "If the client request is triggered by an action URL, the portal/portlet-container " +
+ "must first trigger the action request by invoking the processAction method of the targeted portlet."),
+ JSR286_15(new TCK(15), "PLT.5.4", "The portal/portlet-container must wait until the action request finishes. Then, " +
+ "the portal/portlet-container should call the processEvent methods of the event receiving portlets and after the " +
+ "event processing is finished must trigger the render request by invoking the render method for all the portlets " +
+ "in the portal page with the possible exception of portlets for which their content is being cached."),
+ JSR286_16(new TCK(16), "PLT.5.4", "If the client request is triggered by a render URL, the portal/portlet-container " +
+ "must invoke the render method for all the portlets in the portal page with the possible exception of portlets " +
+ "for which their content is being cached."),
+ JSR286_17(new TCK(17), "PLT.5.4", "If the client request is triggered by a resource URL, the portal/portlet-container " +
+ "must invoke the serveResource method of the target portlet with the possible exception of content that has a " +
+ "valid cache entry."),
+ JSR286_18(new TCK(18), "PLT.5.4.1", "If the portlet issues a redirection, when the processAction method concludes, " +
+ "the portal/portlet-container must send the redirection back to the user agent"),
+ JSR286_19(new TCK(19), "PLT.5.4.5.4", "If no matching annotated method is found GenericPortlet will dispatch to " +
+ "the following methods: doView for handling VIEW requests"),
+ JSR286_20(new TCK(20), "PLT.5.4.5.4", "If no matching annotated method is found GenericPortlet will dispatch to " +
+ "the following methods: doEdit for handling EDIT requests"),
+ JSR286_21(new TCK(21), "PLT.5.4.5.4", "If no matching annotated method is found GenericPortlet will dispatch to " +
+ "the following methods: doHelp for handling HELP requests"),
+ JSR286_22(new TCK(22), "PLT.5.4.5.4", "If the window state of the portlet (see PLT.9 Window States Chapter) is " +
+ "MINIMIZED, the render method of the GenericPortlet does not invoke any of the portlet mode rendering methods"),
+ JSR286_23(new TCK(23), "PLT.5.4.7", "If a portlet throws an exception in the processAction or processEvent method, " +
+ "all operations on the ActionResponse must be ignored including set events."),
+ JSR286_24(new TCK(24), Status.specUntestable(""), "PLT.5.4.7", "If a permanent unavailability is indicated by the " +
+ "UnavailableException, the portlet container must remove the portlet from service immediately, call the portlet’s " +
+ "destroy method, and release the portlet object"),
+ JSR286_25(new TCK(25), "PLT.5.4.7", "A RuntimeException thrown during the request handling must be handled as a " +
+ "PortletException."),
// PLT.6 Portlet Config
JSR286_26(new TCK(26), "PLT.6.2", "If the root resource bundle does not contain the resources for these values and " +
@@ -492,47 +527,89 @@
// PLT,7 Portlet URLs
- JSR286_35(new TCK(35), "", ""),
- JSR286_36(new TCK(36), "", ""),
- JSR286_37(new TCK(37), "", ""),
- JSR286_38(new TCK(38), "", ""),
- JSR286_39(new TCK(39), "", ""),
- JSR286_40(new TCK(40), "", ""),
- JSR286_41(new TCK(41), "", ""),
- JSR286_42(new TCK(42), "", ""),
- JSR286_43(new TCK(43), "", ""),
- JSR286_44(new TCK(45), "", ""),
- JSR286_45(new TCK(44), "", ""),
- JSR286_46(new TCK(46), "", ""),
- JSR286_47(new TCK(47), "", ""),
- JSR286_48(new TCK(48), "", ""),
- JSR286_49(new TCK(49), "", ""),
- JSR286_50(new TCK(50), "", ""),
- JSR286_51(new TCK(51), "", ""),
+ JSR286_35(new TCK(35), "PLT.7.1", "The portal/portlet-container must not invoke the processAction method of the " +
+ "targeted portlet of a render URL."),
+ JSR286_36(new TCK(36), "PLT.7.1", "The portal/portlet-container must ensure that all the parameters set when " +
+ "constructing the render URL become render parameters of the subsequent render requests for the portlet."),
+ JSR286_37(new TCK(37), "PLT.7.1.1", "A call to any of the setParameter methods must replace any parameter with " +
+ "the same name previously set."),
+ JSR286_38(new TCK(38), "PLT.7.1.1", "All the parameters a portlet adds to a BaseURL object must be made available " +
+ "to the portlet as request parameters."),
+ JSR286_39(new TCK(39), "PLT.7.1.1", "The portlet-container must “x-www-form-urlencoded” encode parameter names and " +
+ "values added to a BaseURL object."),
+ JSR286_40(new TCK(40), "PLT.7.1.1", "If a portal/portlet-container encodes additional information as parameters, it " +
+ "must namespace them properly to avoid collisions with the parameters set and used by the portlet."),
+ JSR286_41(new TCK(41), "PLT.7.1.2", "A portlet cannot create a portlet URL using a portlet mode that is not defined " +
+ "as supported by the portlet or that the user it is not allowed to use. The setPortletMode methods must throw a " +
+ "PortletModeException in that situation."),
+ JSR286_42(new TCK(42), "PLT.7.1.2", "The change of portlet mode must be effective for the request triggered by the " +
+ "portlet URL."),
+ JSR286_43(new TCK(43), "PLT.7.1.2", "If the portlet mode is not set for a URL, it must have the portlet mode of the " +
+ "current request as default."),
+ JSR286_44(new TCK(45), "PLT.7.1.2", "A portlet cannot create a portlet URL using a window state that is not supported " +
+ "by the portlet container. The setWindowState method must throw a WindowStateException if that is the case."),
+ JSR286_45(new TCK(44), "PLT.7.1.2", "If the window state is not set for a URL, it must have the window state of the " +
+ "current request as default."),
+ JSR286_46(new TCK(46), "PLT.7.1.3", "If setSecure is called with true, the transport for the request triggered with " +
+ "this URL must be secure (i.e. HTTPS)."),
+ JSR286_47(new TCK(47), "PLT.7.2.1", "If the portlet application has specified one or more PortletURLGenerationListener " +
+ "classes in the portlet deployment descriptor the portlet container must call: the method filterActionURL method for " +
+ "all action URLs before executing the write or toString method of these action URLs"),
+ JSR286_48(new TCK(48), "PLT.7.2.1", "If the portlet application has specified one or more PortletURLGenerationListener " +
+ "classes in the portlet deployment descriptor the portlet container must call: the method filterRenderURL method " +
+ "for all render URLs before executing the write or toString method of these render URLs"),
+ JSR286_49(new TCK(49), "PLT.7.2.1", "If the portlet application has specified one or more PortletURLGenerationListener " +
+ "classes in the portlet deployment descriptor the portlet container must call: the method filterResourceURL method " +
+ "for all resource URLs before executing the write or toString method of these resource URLs"),
+ JSR286_50(new TCK(50), "PLT.7.2.1", "The portlet container must provide the PortletURL or ResourceURL to generate to " +
+ "the filter methods and execute the write or toString method on the updated PortletURL or ResourceURL that is the " +
+ "outcome of the filter method call."),
+ JSR286_51(new TCK(51), "PLT.7.2.2", "If more than one listener is registered the portlet container must chain the " +
+ "listeners in the order of how they appear in the deployment descriptor."),
// PLT.8 Portlet Modes
- JSR286_52(new TCK(52), "", ""),
- JSR286_53(new TCK(53), "", ""),
- JSR286_54(new TCK(54), "", ""),
- JSR286_55(new TCK(55), "", ""),
+ JSR286_52(new TCK(52), "PLT.8.5", "If no matching annotated method is found GenericPortlet will dispatch to the " +
+ "doView, doEdit or doHelp method depending on the portlet mode indicated in the request using the doDispatch " +
+ "method or throws a PortletException if the mode is not VIEW, EDIT, or HELP."),
+ JSR286_53(new TCK(53), "PLT.8.6", "As all portlets must support the VIEW portlet mode, VIEW does not have to be " +
+ "indicated."),
+ JSR286_54(new TCK(54), "PLT.8.6", "The portlet must not be invoked in a portlet mode that has not been declared " +
+ "as supported for a given markup type."),
+ JSR286_55(new TCK(55), Status.specUntestable(""), "PLT.8.6", "The portlet container must ignore all references to " +
+ "custom portlet modes that are not supported by the portal implementation, or that have no mapping to portlet " +
+ "modes supported by the portal."),
// PLT.9 Window States
- JSR286_56(new TCK(56), "", ""),
- JSR286_57(new TCK(57), "", ""),
- JSR286_58(new TCK(58), "", ""),
+ JSR286_56(new TCK(56), "PLT.9.4", "If a custom window state defined in the deployment descriptor is not mapped to " +
+ "a custom window state provided by the portal, portlets must not be invoked in that window state."),
+ JSR286_57(new TCK(57), "PLT.9.5", "As all portlets must at least support the pre-defined window states NORMAL, " +
+ "MAXIMIZED, MINIMIZED, these window states do not have to be indicated."),
+ JSR286_58(new TCK(58), Status.specUntestable(""), "PLT.9.5", "The portlet container must ignore all references " +
+ "to custom window states that are not supported by the portal implementation, or that have no mapping to window " +
+ "states supported by the portal"),
// PLT.10 Portlet Context
- JSR286_59(new TCK(59), "", ""),
- JSR286_60(new TCK(60), "", ""),
- JSR286_61(new TCK(61), "", ""),
- JSR286_62(new TCK(62), "", ""),
- JSR286_63(new TCK(63), "", ""),
- JSR286_64(new TCK(64), "", ""),
- JSR286_65(new TCK(64), "", ""),
- JSR286_66(new TCK(66), "", ""),
+ JSR286_59(new TCK(59), Status.specUntestable(""), "PLT.10.1", "There is one instance of the PortletContext interface " +
+ "associated with each portlet application deployed into a portlet container."),
+ JSR286_60(new TCK(60), Status.specUntestable(""), "PLT.10.1", "In cases where the container is distributed over many " +
+ "virtual machines, a portlet application will have an instance of the PortletContext interface for each VM."),
+ JSR286_61(new TCK(61), "PLT.10.3", "The initialization parameters accessible through the PortletContext must be the " +
+ "same that are accessible through the ServletContext of the portlet application."),
+ JSR286_62(new TCK(62), "PLT.10.3", "A direct consequence of this is that data stored in the ServletContext by " +
+ "servlets or JSPs is accessible to portlets through the PortletContext and vice versa."),
+ JSR286_63(new TCK(63), "PLT.10.3", "The PortletContext must offer access to the same set of resources the " +
+ "ServletContext exposes."),
+ JSR286_64(new TCK(64), "PLT.10.3", "It must be accessible as a context attribute using the same constant " +
+ "defined in the Servlet Specification SVR 3 Servlet Context Chapter, javax.servlet.context.tempdir."),
+ JSR286_65(new TCK(64), "PLT.10.3", "The portlet context must follow the same behavior and functionality that " +
+ "the servlet context has for virtual hosting and reloading considerations. (see Servlet Specification SVR 3 " +
+ "Servlet Context Chapter)"),
+ JSR286_66(new TCK(66), "PLT.10.4.4", "For such use cases the Java Portlet Specification provides the action-scoped " +
+ "request attributes as container runtime option with the intent to provide portlets with these request attributes " +
+ "until a new action occurs. This container runtime option must be supported by portlet containers."),
// PLT.11 Portlet Requests
@@ -567,7 +644,8 @@
"window state of portlets. The URLs these controls use are generated by the portal. Client requests triggered " +
"by those URLs must be treated as render URLs and the existing render parameters must be preserved."),
JSR286_80(new TCK(80), "PLT.11.1.1.3", "A portlet must not see any parameter targeted to other portlets."),
- JSR286_81(new TCK(81), "PLT.11.1.2", "The supportedpublic-render-parameter element must reference the identifier " +
+ JSR286_81(new TCK(81), Status.specUntestable(""), "PLT.11.1.2", "The supportedpublic-render-parameter element must " +
+ "reference the identifier " +
"of a public render parameter defined in the portlet application section in a public-render-parameter element"),
JSR286_82(new TCK(82), "PLT.11.1.2", "The portlet container must only send those public render parameters to a " +
"portlet which the portlet has defined support for using supported-public-render-parameter element in the " +
@@ -582,7 +660,7 @@
JSR286_86(new TCK(86), "PLT.11.1.2", "Portlets can access a merged set of public and private parameters via the " +
"getParameter methods on the PortletRequest or separated as maps of private parameters via the " +
"getPrivateParameterMap method and public parameters via the getPublicParameterMap method."),
- JSR286_87(new TCK(87), JSR168_57, "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
+ JSR286_87(new TCK(87), JSR168_57, Status.specUntestable(""), "PLT.11.1.3", "Extra parameters used by the portal/portlet-container must be invisible " +
"to the portlets receiving the request."),
JSR286_88(new TCK(88), "PLT.11.1.4.1", "The portlet can access a map with user information attributes via the " +
"request attribute PortletRequest.USER_INFO."),
@@ -620,47 +698,80 @@
// PLT.12 Portlet Responses
- JSR286_100(new TCK(100), "", ""),
- JSR286_101(new TCK(101), "", ""),
- JSR286_102(new TCK(102), "", ""),
- JSR286_103(new TCK(103), "Using the setRenderParameter and setRenderParameters methods portlets may set " +
- "render parameters. A call to any of the setRenderParameter methods must replace any " +
+ JSR286_100(new TCK(100), "PLT.12.1.3", "The getNamespace method must provide the portlet with a mechanism that " +
+ "ensures the uniqueness of the returned string in the whole portal page"),
+ JSR286_101(new TCK(101), "PLT.12.1.3", "The getNamespace method must return the same value for the lifetime of " +
+ "the portlet window."),
+ JSR286_102(new TCK(102), "PLT.12.1.3", "The getNamespace method must return a valid identifier as defined in the " +
+ "3.8 Identifier Section of the Java Language Specification Second Edition."),
+ JSR286_103(new TCK(103), "PLT.12.2.1", "A call to any of the setRenderParameter methods must replace any " +
"parameter with the same name previously set."),
+ JSR286_104(new TCK(104), "PLT.12.2.2", "If a portlet attempts to set a portlet mode that it is not allowed to switch " +
+ "to, a PortletModeException must be thrown."),
+ JSR286_105(new TCK(105), "PLT.12.2.2", "If a portlet attempts to set a window state that it is not allowed to switch " +
+ "to, a WindowStateException must be thrown."),
+ JSR286_106(new TCK(106), "PLT.12.3.1", "The sendRedirect(String location) method instructs the portal/portlet-container " +
+ "to set the appropriate headers and content body to redirect the user to a different URL. A fully qualified URL " +
+ "or a full path URL must be specified. If a relative path URL is given, an IllegalArgumentException must be thrown."),
+ JSR286_107(new TCK(107), "PLT.12.3.1", "If the sendRedirect(String location) method is called after the setPortletMode, " +
+ "setWindowState, setRenderParameter or setRenderParameters methods of the ActionResponse interface, an " +
+ "IllegalStateException must be thrown and the redirection must not be executed."),
+ JSR286_108(new TCK(108), "PLT.12.3.1", "If a relative path URL is given, an IllegalArgumentException must be thrown."),
+ JSR286_109(new TCK(109), "PLT.12.3.1", "The portlet container must attach a render URL with the currently set " +
+ "portlet mode, window state and render parameters on the ActionResponse and the current public render parameters."),
+ JSR286_110(new TCK(110), "PLT.12.3.1", "The attached URL must be available as query parameter value under the " +
+ "key provided with the renderUrlParamName parameter."),
+ JSR286_111(new TCK(111), "PLT.12.3.1", "New values for portlet mode, window state, private or public render " +
+ "parameters must be encoded in the attached render URLcxi,"),
+ JSR286_112(new TCK(112), "PLT.12.3.1", "For the render response the setContentType method must throw an " +
+ "IllegalArgumentException if the content type set does not match (including wildcard matching) any of the " +
+ "content types returned by the getResponseContentType method of the PortletRequest objectcxii."),
+ JSR286_113(new TCK(113), "PLT.12.3.1", "If the portlet has set a content type, the getContentType method must " +
+ "return it. Otherwise, the getContentType method must return null."),
+ JSR286_114(new TCK(114), "PLT.12.5.2", "A portlet may generate its content by writing to the OutputStream or to " +
+ "the Writer of the MimeResponse object. A portlet must use only one of these objects. The portlet container must " +
+ "throw an IllegalStateException if a portlet attempts to use both."),
+ JSR286_115(new TCK(115), "PLT.12.5.5", "The getBufferSize method returns the size of the underlying buffer being " +
+ "used. If no buffering is being used, this method must return the int value of 0 (zero)."),
+ JSR286_116(new TCK(116), "PLT.12.5.5", "The portlet can request a preferred buffer size by using the setBufferSize " +
+ "method. The buffer assigned is not required to be the size requested by the portlet, but must be at least as " +
+ "large as the size requested."),
+ JSR286_117(new TCK(117), "PLT.12.5.5", "The reset method clears data in the buffer when the response is not " +
+ "committed. Properties set by the portlet prior to the reset call must be cleared as well."),
+ JSR286_118(new TCK(118), "PLT.12.5.5", "If the response is committed and the reset or resetBuffer method is called, " +
+ "an IllegalStateException must be thrown."),
+ JSR286_119(new TCK(119), "PLT.12.5.5", "The response and its associated buffer must be unchanged."),
+ JSR286_120(new TCK(120), "PLT.12.5.5", "When using a buffer, the container must immediately flush the contents of " +
+ "a filled buffer to the portal application."),
+ JSR286_121(new TCK(121), Status.specUntestable(""), "PLT.12.6.1", "The setTitle method must be called before the " +
+ "output of the portlet has been committed, if called after it should be ignored."),
- JSR286_104(new TCK(104), "", ""),
- JSR286_105(new TCK(105), "", ""),
- JSR286_106(new TCK(106), "", ""),
- JSR286_107(new TCK(107), "", ""),
- JSR286_108(new TCK(108), "", ""),
- JSR286_109(new TCK(109), "", ""),
- JSR286_110(new TCK(110), "", ""),
- JSR286_111(new TCK(111), "", ""),
- JSR286_112(new TCK(112), "", ""),
- JSR286_113(new TCK(113), "", ""),
- JSR286_114(new TCK(114), "", ""),
- JSR286_115(new TCK(115), "", ""),
- JSR286_116(new TCK(116), "", ""),
- JSR286_117(new TCK(117), "", ""),
- JSR286_118(new TCK(118), "", ""),
- JSR286_119(new TCK(119), "", ""),
- JSR286_120(new TCK(120), "", ""),
- JSR286_121(new TCK(121), "", ""),
-
-
// PLT.13 Resource Serving
- JSR286_122(new TCK(122), "", ""),
- JSR286_123(new TCK(123), "", ""),
- JSR286_124(new TCK(124), "", ""),
- JSR286_125(new TCK(125), "", ""),
- JSR286_126(new TCK(126), "", ""),
- JSR286_127(new TCK(127), "", ""),
- JSR286_128(new TCK(128), "", ""),
- JSR286_129(new TCK(129), "", ""),
- JSR286_130(new TCK(130), "", ""),
- JSR286_131(new TCK(131), "", ""),
- JSR286_132(new TCK(132), "", ""),
+ JSR286_122(new TCK(122), "PLT.13.1.4", "The portlet must be able to get the HTTP method with which this request " +
+ "was made, for example, GET, POST, or PUT, via the getMethod call on the ResourceRequest."),
+ JSR286_123(new TCK(123), "PLT.13.1.5", "The portlet must be able to get the resource ID that was set on the resource " +
+ "URL with the setResourceID method via the getResourceID method from the resource request."),
+ JSR286_124(new TCK(124), "PLT.13.1.5", "If no resource ID was set on the resource URL the getResourceID method must " +
+ "return null."),
+ JSR286_125(new TCK(125), "PLT.13.1.6", "When an end user invokes such a resource URL the portlet container must " +
+ "call the serveResource method of the portlet or return a valid cached result for this resource URL"),
+ JSR286_126(new TCK(126), "PLT.13.1.6", "The portlet container must not call the processAction or processEvent " +
+ "method."),
+ JSR286_127(new TCK(127), "PLT.13.1.6", "ResourceURLs cannot change the current portlet mode, window state or " +
+ "render parameters"),
+ JSR286_128(new TCK(128), "PLT.13.1.6", "If a parameter is set that has the same name as a render parameter that " +
+ "this resource URL contains, the render parameter values must be the last entries in the parameter value array."),
+ JSR286_129(new TCK(129), "PLT.13.1.7", "If portlet URLs are included in the markup, portals / portlet containers " +
+ "must create correct portlet URLs for all text-based markup types."),
+ JSR286_130(new TCK(130), "PLT.13.1.7", "Setting a cachability different from FULL must result in an " +
+ "IllegalStateException"),
+ JSR286_131(new TCK(131), "PLT.13.1.7", "Attempts to create URLs that are not of type FULL or are not resource " +
+ "URLs in the current or a downstream response must result in\n" +
+ "an IllegalStateException"),
+ JSR286_132(new TCK(132), "PLT.13.1.7", "Creating other URLs, e.g. resource URLs of type PAGE or action or render " +
+ "URLs, must result in an IllegalStateException"),
// PLT.14 Serving Fragments through Portlets
@@ -702,40 +813,79 @@
// PLT.17 Portlet Preferences
- JSR286_148(new TCK(148), "", ""),
+ JSR286_148(new TCK(148), "PLT.17.1", "Preferences attributes can be set to null"),
+ JSR286_149(new TCK(149), "PLT.17.1", "Preferences values must not be modified if the values in the Map are altered"),
+ JSR286_150(new TCK(150), "PLT.17.1", "The reset method must reset a preference attribute to its default value. " +
+ "If there is no default value, the preference attribute must be deleted."),
+ JSR286_151(new TCK(151), "PLT.17.1", "If a preference attribute is read only, the setValue, setValues and reset " +
+ "methods must throw a ReadOnlyException when the portlet is in any of the standard modes."),
+ JSR286_152(new TCK(152), "PLT.17.1", "The store method must persist all the changes made to the PortletPreferences " +
+ "object in the persistent store."),
+ JSR286_153(new TCK(153), "PLT.17.1", "The store method must be conducted as an atomic transaction regardless of how " +
+ "many preference attributes have been modified."),
+ JSR286_154(new TCK(154), "PLT.17.1", "All changes made to PortletPreferences object not followed by a call to the " +
+ "store method must be discarded when the portlet finishes the processAction, processEvent, or serveResource method."),
+ JSR286_155(new TCK(155), "PLT.17.1", "If the store method is invoked within the scope of a render method invocation, " +
+ "it must throw an IllegalStateException."),
+ JSR286_156(new TCK(156), "PLT.17.1", "The PortletPreferences object must reflect the current values of the " +
+ "persistent store when the portlet container invokes the processAction, processEvent, render and serveResource " +
+ "methods of the portlet."),
+ JSR286_157(new TCK(157), "PLT.17.3", "If a preference attribute definition does not contain the read-only element " +
+ "set to true, the preference attribute is modifiable when the portlet is processing an action request in any " +
+ "of the standard portlet modes (VIEW, EDIT or HELP)."),
+ JSR286_158(new TCK(158), "PLT.17.3", "Portlets are not restricted to use preference attributes defined in the " +
+ "deployment descriptor. They can programmatically add preference attributes using names not defined in the " +
+ "deployment descriptor. These preferences attributes must be treated as modifiable attributes."),
+ JSR286_159(new TCK(159), "PLT.17.4", "When a validator is associated with the preferences of a portlet definition, " +
+ "the store method of the PortletPreferences implementation must invoke the validate method of the validator " +
+ "before writing the changes to the persistent store."),
+ JSR286_160(new TCK(160), "PLT.17.4", "If a ValidatorException is thrown, the portlet container must cancel the " +
+ "store operation and it must propagate the exception to the portlet."),
+ JSR286_161(new TCK(161), "PLT.17.4", "If the validation is successful, the store operation must be completed"),
- JSR286_149(new TCK(149), "", ""),
- JSR286_150(new TCK(150), "", ""),
- JSR286_151(new TCK(151), "", ""),
- JSR286_152(new TCK(152), "", ""),
- JSR286_153(new TCK(153), "", ""),
- JSR286_154(new TCK(154), "", ""),
- JSR286_155(new TCK(155), "", ""),
- JSR286_156(new TCK(156), "", ""),
- JSR286_157(new TCK(157), "", ""),
- JSR286_158(new TCK(158), "", ""),
- JSR286_159(new TCK(159), "", ""),
- JSR286_160(new TCK(160), "", ""),
- JSR286_161(new TCK(161), "", ""),
-
// PLT.18 Sessions
- JSR286_162(new TCK(162), "", ""),
- JSR286_163(new TCK(163), "", ""),
- JSR286_164(new TCK(164), "", ""),
- JSR286_165(new TCK(165), "", ""),
- JSR286_166(new TCK(166), "", ""),
- JSR286_167(new TCK(167), "", ""),
- JSR286_168(new TCK(168), "", ""),
- JSR286_169(new TCK(169), "", ""),
- JSR286_170(new TCK(170), "", ""),
- JSR286_171(new TCK(171), "", ""),
- JSR286_172(new TCK(172), "", ""),
- JSR286_173(new TCK(173), "", ""),
- JSR286_174(new TCK(174), "", ""),
- JSR286_175(new TCK(175), "", ""),
- JSR286_176(new TCK(176), "", ""),
+ JSR286_162(new TCK(162), "PLT.18.1", "For portlets within the same portlet application, a portlet container must " +
+ "ensure that every portlet request generated as result of a group of requests originated from the portal to " +
+ "complete a single client request receive or acquire the same session."),
+ JSR286_163(new TCK(163), "PLT.18.1", "In addition, if within these portlet requests more than one portlet creates " +
+ "a session, the session object must be the same for all the portlets in the same portlet application"),
+ JSR286_164(new TCK(164), "PLT.18.2", "PortletSession objects must be scoped at the portlet application context level."),
+ JSR286_165(new TCK(165), "PLT.18.2", "The portlet container must not share the PortletSession object or the " +
+ "attributes stored in it among different portlet applications or among different user sessions."),
+ JSR286_166(new TCK(166), "PLT.18.3", "Any object stored in the session using the APPLICATION_SCOPE is available " +
+ "to any other portlet that belongs to the same portlet application and that handles a request identified as " +
+ "being a part of the same session."),
+ JSR286_167(new TCK(167), "PLT.18.3", "Objects stored in the session using the PORTLET_SCOPE must be available to " +
+ "the portlet during requests for the same portlet window that the objects where stored from."),
+ JSR286_168(new TCK(168), "PLT.18.3", "The object must be stored in the APPLICATION_SCOPE with the following " +
+ "fabricated attribute name ‘javax.portlet.p.<ID>?<ATTRIBUTE_NAME>’. <ID> is a unique identification for the " +
+ "portlet window (assigned by the portal/portlet-container) that must be equal to the ID returned by the PortletRequest.getWindowID() method and not contain a ‘?’ character."),
+ JSR286_169(new TCK(169), "PLT.18.4", "The container must ensure that all attributes placed in the PortletSession " +
+ "are also available in the HttpSession of the portlet application. A direct consequence of this is that data " +
+ "stored in the HttpSession by servlets or JSPs of the Portlet Application is accessible to portlets through " +
+ "the PortletSession in the portlet application scope."),
+ JSR286_170(new TCK(170), "PLT.18.4", "Conversely, data stored by portlets in the PortletSession in the portlet " +
+ "application scope is accessible to servlets and JSPs through the HttpSession."),
+ JSR286_171(new TCK(171), "PLT.18.4", "If the HttpSession object is invalidated, the PortletSession object must " +
+ "also be invalidated by the portlet container."),
+ JSR286_172(new TCK(172), "PLT.18.4", "If the PortletSession object is invalidated by a portlet, the portlet " +
+ "container must invalidate the associated HttpSession object."),
+ JSR286_173(new TCK(173), "PLT.18.4.1", "The getAttribute, setAttribute, removeAttribute and getAttributeNames " +
+ "methods of the PortletSession interface must provide the same functionality as the methods of the HttpSession " +
+ "interface with identical names adhering to the following rules: The attribute names must be the same if " +
+ "APPLICATION_SCOPE scope is used."),
+ JSR286_174(new TCK(174), "PLT.18.4.1", "The getAttribute, setAttribute, removeAttribute and getAttributeNames " +
+ "methods of the PortletSession interface must provide the same functionality as the methods of the HttpSession " +
+ "interface with identical names adhering to the following rules: The attribute name has to conform with the " +
+ "specified prefixing if PORTLET_SCOPE is used."),
+ JSR286_175(new TCK(175), "PLT.18.4.1", "The getAttribute, setAttribute, removeAttribute and getAttributeNames " +
+ "methods of the PortletSession interface must provide the same functionality as the methods of the HttpSession " +
+ "interface with identical names adhering to the following rules: The variant of these methods that does not " +
+ "receive a scope must be treated as PORTLET_SCOPE."),
+ JSR286_176(new TCK(176), "PLT.18.9(servlet spec)", "These considerations include Threading Issues, Distributed " +
+ "Environments and Client Semantics."),
@@ -805,7 +955,7 @@
"outputstream / writer that ignores any output written to it: getOutputStream and getWriter."),
JSR286_200(new TCK(200), "PLT.19.3.3", "The following methods of the HttpServletResponse must be equivalent " +
"to the methods of the ActionResponse/EventResponse of similar name: encodeURL and encodeUrl."),
- JSR286_201(new TCK(201), "PLT.19.3.3", "The following methods of the HttpServletResponse must perform no " +
+ JSR286_201(new TCK(201), Status.specUntestable("impl"), "PLT.19.3.3", "The following methods of the HttpServletResponse must perform no " +
"operations: setContentType, setCharacterEncoding, setContentLength, setLocale, addCookie, sendError, " +
"sendRedirect, setDateHeader, addDateHeader, setHeader, addHeader, setIntHeader, addIntHeader, setStatus,\n" +
"setBufferSize and flushBuffer."),
@@ -843,7 +993,7 @@
JSR286_216(new TCK(216), "PLT.19.3.4", "The following methods of the HttpServletResponse must be equivalent " +
"to the methods of the RenderResponse of similar name: getCharacterEncoding, setBufferSize, flushBuffer, " +
"resetBuffer, reset, getBufferSize, isCommitted, getOutputStream, getWriter, encodeURL and encodeUrl."),
- JSR286_217(new TCK(217), "PLT.19.3.4", "The following methods of the HttpServletResponse must perform no " +
+ JSR286_217(new TCK(217), Status.specUntestable("impl"), "PLT.19.3.4", "The following methods of the HttpServletResponse must perform no " +
"operations: setContentType, setContentLength, setLocale, addCookie, sendError, sendRedirect, setDateHeader, " +
"addDateHeader, setHeader, addHeader, setIntHeader, addIntHeader and setStatus."),
JSR286_218(new TCK(218), "PLT.19.3.4", "The containsHeader method of the HttpServletResponse must return false."),
@@ -880,7 +1030,7 @@
JSR286_230(new TCK(230), "PLT.19.3.5", "The following methods of the HttpServletResponse must be equivalent " +
"to the methods of the ResourceResponse of similar name: getCharacterEncoding, setBufferSize, flushBuffer, " +
"resetBuffer, reset, getBufferSize, isCommitted, getOutputStream, getWriter, getLocale, encodeURL and encodeUrl."),
- JSR286_231(new TCK(231), "PLT.19.3.5", "The following methods of the HttpServletResponse must perform no " +
+ JSR286_231(new TCK(231), Status.specUntestable("impl"), "PLT.19.3.5", "The following methods of the HttpServletResponse must perform no " +
"operations: sendError, sendRedirect, addCookie, setDateHeader, addDateHeader, setHeader, addHeader, " +
"setIntHeader, addIntHeader, setContentLength, setCharacterEncoding, setContentType, setLocale and setStatus."),
JSR286_232(new TCK(232), "PLT.19.3.5", "The containsHeader method of the HttpServletResponse must return false."),
@@ -950,11 +1100,11 @@
"outputstream / writer that ignores any output written to it: getOutputStream and getWriter."),
JSR286_257(new TCK(257), "PLT.19.4.3", "The following methods of the HttpServletResponse must be equivalent " +
"to the methods of the ActionResponse/EventResponse of similar name: encodeURL and encodeUrl."),
- JSR286_258(new TCK(258), "PLT.19.4.3", "The following methods of the HttpServletResponse must perform no " +
+ JSR286_258(new TCK(258), Status.specUntestable("imp"), "PLT.19.4.3", "The following methods of the HttpServletResponse must perform no " +
"operations: resetBuffer, reset, setContentType, setContentLength,\n" +
"setCharacterEncoding, setLocale, sendError, setDateHeader, addDateHeader, setHeader, addHeader, setIntHeader, " +
"addIntHeader, setStatus, setBufferSize and flushBuffer."),
- JSR286_259(new TCK(259), "PLT.19.4.3", "The addCookie method of the HttpServletResponse must be based on " +
+ JSR286_259(new TCK(259), Status.specUntestable("impl"), "PLT.19.4.3", "The addCookie method of the HttpServletResponse must be based on " +
"addProperty method of the ActionResponse/EventResponse interface."),
JSR286_260(new TCK(260), "PLT.19.4.3", "The containsHeader method of the HttpServletResponse must return false."),
JSR286_261(new TCK(261), "PLT.19.4.3", "The isCommitted method of the HttpServletResponse must return false."),
@@ -991,9 +1141,9 @@
"to the methods of the RenderResponse of similar name: getCharacterEncoding, setBufferSize, flushBuffer, " +
"resetBuffer, reset, getBufferSize, getLocale, isCommitted, getOutputStream, getWriter, setContentType, " +
"encodeURL and encodeUrl."),
- JSR286_275(new TCK(275), "PLT.19.4.4", "The following methods of the HttpServletResponse must perform no " +
+ JSR286_275(new TCK(275), Status.specUntestable("impl"), "PLT.19.4.4", "The following methods of the HttpServletResponse must perform no " +
"operations: setContentLength, setLocale, sendError, sendRedirect, and setStatus."),
- JSR286_276(new TCK(276), "PLT.19.4.4", "The containsHeader method of the HttpServletResponse must return false."),
+ JSR286_276(new TCK(276), Status.specUntestable("impl"), "PLT.19.4.4", "The containsHeader method of the HttpServletResponse must return false."),
JSR286_277(new TCK(277), "PLT.19.4.4", "The following methods of the HttpServletResponse must be based on " +
"the properties provided by the setProperties/addProperties method of the RenderResponse interface: addCookie, " +
"setDateHeader, addDateHeader, setHeader, addHeader, setIntHeader, addIntHeader."),
@@ -1028,9 +1178,9 @@
"to the methods of the ResourceResponse of similar name: getCharacterEncoding, setContentType, setBufferSize, " +
"flushBuffer, resetBuffer, reset, getBufferSize, isCommitted, getOutputStream, getWriter, getLocale, encodeURL " +
"and encodeUrl."),
- JSR286_289(new TCK(289), "PLT.19.4.5", "The following methods of the HttpServletResponse must perform no operations: " +
+ JSR286_289(new TCK(289), Status.specUntestable("impl"), "PLT.19.4.5", "The following methods of the HttpServletResponse must perform no operations: " +
"sendError, sendRedirect."),
- JSR286_290(new TCK(290), "PLT.19.4.5", "The containsHeader method of the HttpServletResponse must return false."),
+ JSR286_290(new TCK(290), Status.specUntestable("impl"), "PLT.19.4.5", "The containsHeader method of the HttpServletResponse must return false."),
//
JSR286_291(new TCK(291), "PLT.19.5", "Since the Java Servlet Specification V2.4 you can specify servlet filters " +
@@ -1059,14 +1209,21 @@
"filter or one of the above mentioned wrappers."),
JSR286_297(new TCK(297), "PLT.20.2.4", "The portlet container must instantiate exactly one instance of the Java " +
"class defining the filter per filter declaration in the deployment descriptor."),
- JSR286_298(new TCK(298), "PLT.20.2.4", "Filters can be associated with groups of portlets using the ‘*’ character as a wildcard at the end of a string to indicate that the filter must be applied to any portlet whose name starts with the characters before the “*” character."),
- JSR286_299(new TCK(299), "PLT.20.2.4", "The portlet container is free to add additional filters at any place in this filter chain, but must not remove filters matching a specific portlet."),
- JSR286_300(new TCK(300), "PLT.20.2.5", "A portlet filter can be applied to different lifecycle method calls: processAction, processEvent, render, serveResource"),
- JSR286_301(new TCK(301), "PLT.20.2.5", "Thus the filter must define the lifecycle method for which the filter is written in the <lifecycle> element of the <filter> element."),
+ JSR286_298(new TCK(298), "PLT.20.2.4", "Filters can be associated with groups of portlets using the ‘*’ character as " +
+ "a wildcard at the end of a string to indicate that the filter must be applied to any portlet whose name starts " +
+ "with the characters before the “*” character."),
+ JSR286_299(new TCK(299), "PLT.20.2.4", "The portlet container is free to add additional filters at any place in this " +
+ "filter chain, but must not remove filters matching a specific portlet."),
+ JSR286_300(new TCK(300), "PLT.20.2.5", "A portlet filter can be applied to different lifecycle method calls: " +
+ "processAction, processEvent, render, serveResource"),
+ JSR286_301(new TCK(301), "PLT.20.2.5", "Thus the filter must define the lifecycle method for which the filter " +
+ "is written in the <lifecycle> element of the <filter> element."),
// PLT.21 User Information
- JSR286_302(new TCK(302), "", ""),
+ JSR286_302(new TCK(302), Status.specUntestable("impl"), "PLT.21.2", "If the request is done in the context of " +
+ "an un-authenticated user, calls to the getAttribute method of the request using the USER_INFO constant must " +
+ "return null."),
// PLT.22 Caching
@@ -1075,20 +1232,31 @@
// PLT.23 Portlet Applications
- JSR286_303(new TCK(303), "", ""),
- JSR286_304(new TCK(304), "", ""),
- JSR286_305(new TCK(305), "", ""),
- JSR286_306(new TCK(306), "", ""),
+ JSR286_303(new TCK(303), Status.specUntestable(""), "PLT.23.2", "The portlet container must enforce a one to one " +
+ "correspondence between a portlet application and a PortletContext."),
+ JSR286_304(new TCK(304), Status.specUntestable(""), "PLT.23.2", "If the application is a distributed application, " +
+ "the portlet container must create an instance per VM."),
+ JSR286_305(new TCK(305), Status.specUntestable(""), "PLT.23.5", "The portlet container must use the same classloader " +
+ "the servlet container uses for the web application resources for loading the portlets and related resources " +
+ "within the portlet application."),
+ JSR286_306(new TCK(306), "PLT.23.5(servlet spec)", "The portlet container must ensure that requirements defined " +
+ "in the Servlet Specification SRV.9.7.1 and SRV.9.7.2 Sections are fulfilled."),
// PLT.24 Security
- JSR286_307(new TCK(307), "", ""),
- JSR286_308(new TCK(308), "", ""),
- JSR286_309(new TCK(309), "", ""),
- JSR286_310(new TCK(310), "", ""),
- JSR286_311(new TCK(311), "", ""),
+ JSR286_307(new TCK(307), "PLT.24.2", "The values that the Portlet API getRemoteUser and getUserPrincipal methods " +
+ "return the same values returned by the equivalent methods of the servlet response object."),
+ JSR286_308(new TCK(308), "PLT.24.3", "The container uses the mapping of security-role-ref to security-role when " +
+ "determining the return value of the call."),
+ JSR286_309(new TCK(309), "PLT.24.3", "If the security-role-ref element does not define a role-link element, the " +
+ "container must default to checking the role-name element argument against the list of securityrole elements " +
+ "defined in the web.xml deployment descriptor of the portlet application."),
+ JSR286_310(new TCK(310), "PLT.24.4", "When it is specified, the container must propagate the security identity of " +
+ "the caller to the EJB layer in terms of the security role name defined in the run-as element."),
+ JSR286_311(new TCK(311), "PLT.24.4", "The security role name must be one of the security role names defined for the " +
+ "web.xml deployment descriptor."),
@@ -1098,20 +1266,27 @@
JSR286_312(new TCK(312), "PLT.26.1", "The portlet-container must provide an implementation of the portlet tag library"),
- JSR286_313(new TCK(313), "PLT.26.1", "The defineObjects tag must define the following variables in the JSP page: [REF TO THE SPEC]"),
- JSR286_314(new TCK(314), "PLT.26.2", "The defineObjects tag must not define any attribute and it must not contain any body content"),
- JSR286_315(new TCK(315), "PLT.26.2", "The portlet actionURL tag creates a URL that must point to the current portlet and must trigger an action request with the supplied parameters"),
- JSR286_316(new TCK(316), "PLT.26.2", "If the specified window state is illegal for the current request, a JspException must be thrown."),
- JSR286_317(new TCK(317), "PLT.26.2", "If a window state is notset for a URL, it should stay the same as the window state of the current request."),
- JSR286_318(new TCK(318), "PLT.26.2", "portletMode (Type: String, non-required) – indicates the portlet mode that the portlet must have when this link is executed, if no error condition ocurred"),
- JSR286_319(new TCK(319), "PLT.26.2", "If the specified portlet mode is illegal for the current request, a JspException must be thrown."),
+ JSR286_313(new TCK(313), "PLT.26.1", "The defineObjects tag must define the following variables in the JSP page: " +
+ "[REF TO THE SPEC]"),
+ JSR286_314(new TCK(314), Status.specUntestable(""), "PLT.26.2", "The defineObjects tag must not define any " +
+ "attribute and it must not contain any body content"),
+ JSR286_315(new TCK(315), "PLT.26.2", "The portlet actionURL tag creates a URL that must point to the current " +
+ "portlet and must trigger an action request with the supplied parameters"),
+ JSR286_316(new TCK(316), "PLT.26.2", "If the specified window state is illegal for the current request, a" +
+ " JspException must be thrown."),
+ JSR286_317(new TCK(317), "PLT.26.2", "If a window state is notset for a URL, it should stay the same as the " +
+ "window state of the current request."),
+ JSR286_318(new TCK(318), "PLT.26.2", "portletMode (Type: String, non-required) – indicates the portlet mode " +
+ "that the portlet must have when this link is executed, if no error condition ocurred"),
+ JSR286_319(new TCK(319), "PLT.26.2", "If the specified portlet mode is illegal for the current request, a " +
+ "JspException must be thrown."),
JSR286_320(new TCK(320), "PLT.26.2", ""),
JSR286_321(new TCK(321), "PLT.26.2", ""),
JSR286_322(new TCK(322), "PLT.26.2", ""),
- JSR286_323(new TCK(323), "PLT.26.2", ""),
- JSR286_324(new TCK(324), "PLT.26.2", ""),
- JSR286_325(new TCK(325), "PLT.26.2", ""),
- JSR286_326(new TCK(326), "PLT.26.2", ""),
+ JSR286_323(new TCK(323), Status.specUntestable(""), "PLT.26.2", ""),
+ JSR286_324(new TCK(324), Status.specUntestable(""), "PLT.26.2", ""),
+ JSR286_325(new TCK(325), Status.specUntestable(""), "PLT.26.2", ""),
+ JSR286_326(new TCK(326), Status.specUntestable(""), "PLT.26.2", ""),
JSR286_327(new TCK(327), "PLT.26.3", ""),
JSR286_328(new TCK(328), "PLT.26.3", ""),
JSR286_329(new TCK(329), "PLT.26.3", ""),
@@ -1120,10 +1295,10 @@
JSR286_332(new TCK(332), "PLT.26.3", ""),
JSR286_333(new TCK(333), "PLT.26.3", ""),
JSR286_334(new TCK(334), "PLT.26.3", ""),
- JSR286_335(new TCK(335), "PLT.26.3", ""),
- JSR286_336(new TCK(336), "PLT.26.3", ""),
- JSR286_337(new TCK(337), "PLT.26.3", ""),
- JSR286_338(new TCK(338), "PLT.26.3", ""),
+ JSR286_335(new TCK(335), Status.specUntestable(""), "PLT.26.3", ""),
+ JSR286_336(new TCK(336), Status.specUntestable(""), "PLT.26.3", ""),
+ JSR286_337(new TCK(337), Status.specUntestable(""), "PLT.26.3", ""),
+ JSR286_338(new TCK(338), Status.specUntestable(""), "PLT.26.3", ""),
JSR286_339(new TCK(339), "PLT.26.4", ""),
JSR286_340(new TCK(340), "PLT.26.4", ""),
JSR286_341(new TCK(341), "PLT.26.4", ""),
@@ -1316,20 +1491,20 @@
Assertion(Ref ref, String description)
{
- this(ref, description, new Active());
+ this(ref, new Active(), description);
}
Assertion(Ref ref, String section, String description)
{
- this(ref, description, section, new Active());
+ this(ref, new Active(), description, section);
}
Assertion(Ref ref, Assertion assertion, String section, String description)
{
- this(ref, assertion, description, section, new Active());
+ this(ref, assertion, new Active(), description, section);
}
- Assertion(Ref ref, String description, Status status)
+ Assertion(Ref ref, Status status, String description)
{
this.ref = ref;
this.description = description;
@@ -1337,7 +1512,7 @@
this.status = status;
}
- Assertion(Ref ref, String section, String description, Status status)
+ Assertion(Ref ref, Status status, String section, String description)
{
this.ref = ref;
this.description = description;
@@ -1345,7 +1520,7 @@
this.status = status;
}
- Assertion(Ref ref, Assertion assertion, String section, String description, Status status)
+ Assertion(Ref ref, Assertion assertion, Status status, String section, String description)
{
this.ref = ref;
this.description = description;
16 years, 2 months
JBoss Portal SVN: r9682 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 06:18:50 -0500 (Thu, 31 Jan 2008)
New Revision: 9682
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
Log:
added base class for controller response
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-31 11:14:00 UTC (rev 9681)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-31 11:18:50 UTC (rev 9682)
@@ -839,6 +839,26 @@
}
}
+ /**
+ * Must be used as base class for high level response provided by the controller that
+ * will be translated into something at the portal level. The goal is to avoid to manipulate
+ * the HTTP response directly.
+ *
+ * The test bed will of course use the HTTP response but the Presentation Framework will
+ * work differently.
+ *
+ * So we really need to abstract everything done with the HttpServletResponse and *never* use
+ * it in the controller.
+ *
+ * Typical usage should be :
+ * ControllerResponse response = controller.invoker(ControllerRequest request);
+ *
+ */
+ static class ControllerResponse
+ {
+
+ }
+
static class ControllerRequest
{
/** . */
16 years, 2 months
JBoss Portal SVN: r9681 - in modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test: event and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-01-31 06:14:00 -0500 (Thu, 31 Jan 2008)
New Revision: 9681
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/Event.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContextImpl.java
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/PortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
Log:
- introduced event controller context
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-31 10:32:11 UTC (rev 9680)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -34,6 +34,9 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
+import org.jboss.portal.portlet.test.event.Event;
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.impl.spi.AbstractPortalContext;
@@ -44,7 +47,6 @@
import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
import org.jboss.portal.portlet.info.NavigationInfo;
import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
@@ -74,9 +76,9 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.LinkedList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -133,6 +135,9 @@
PortletControllerContext context = portletRequest.controllerContext;
//
+ PortletContext portletContext = portletRequest.controllerContext.getPortlet(portletRequest.portletId).getContext();
+
+ //
PortletInvocationResponse response = invoke(portletRequest);
//
@@ -172,61 +177,58 @@
}
}
+ //
+ EventControllerContext eventCC = context.getEventControllerContext();
StateResponse stateResponse = (StateResponse)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());
+ LinkedList<Event> eventQueue = new LinkedList<Event>();
+ for (StateResponse.Event portletEvent : stateResponse.getEvents())
+ {
+ Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
+ List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
+ eventQueue.addAll(consumedEvents);
+ }
// Deliver events
- while (queue.size() > 0)
+ while (eventQueue.size() > 0)
{
- StateResponse.Event event = queue.removeFirst();
+ Event event = eventQueue.removeFirst();
//
- List<Portlet> consumers = new ArrayList<Portlet>();
- for (Portlet portlet : context.getPortlets())
- {
- PortletInfo portletInfo = portlet.getInfo();
+ PortletInvocationResponse eventResponse = deliverEvent(context, event, portletRequest.pageState, requestProperties.getCookies());
- if (portletInfo.getEventing().getConsumedEvents().containsKey(event.getName()))
- {
- consumers.add(portlet);
- }
- }
-
//
- for (Portlet consumer : consumers)
+ if (eventResponse instanceof UpdateNavigationalStateResponse)
{
- PortletInvocationResponse eventResponse =
- deliverEvent(context, consumer, event, portletRequest.pageState, requestProperties.getCookies());
+ UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
- //
- if (eventResponse instanceof UpdateNavigationalStateResponse)
- {
- UpdateNavigationalStateResponse update = (UpdateNavigationalStateResponse)eventResponse;
+ // Update ns
+ updateNavigationalState(context, event.getPortletContext().getId(), update, portletRequest.pageState);
- // Update ns
- updateNavigationalState(context, consumer.getContext().getId(), update, portletRequest.pageState);
-
- // Add events if any
- queue.addAll(update.getEvents());
-
- //
- ResponseProperties updateProperties = update.getProperties();
- if (updateProperties != null)
- {
- requestProperties.append(updateProperties);
- }
- }
- else if (eventResponse instanceof ErrorResponse)
+ // Add events if any
+ for (StateResponse.Event portletEvent : update.getEvents())
{
- // Do something here !!!!
+ Event producedEvent = new Event(portletEvent.getName(), portletEvent.getPayload(), portletContext);
+ List<Event> consumedEvents = eventCC.getConsumedEvents(producedEvent);
+ eventQueue.addAll(consumedEvents);
}
- else
+
+ //
+ ResponseProperties updateProperties = update.getProperties();
+ if (updateProperties != null)
{
- // Do something here !!!!
+ requestProperties.append(updateProperties);
}
}
+ else if (eventResponse instanceof ErrorResponse)
+ {
+ // Do something here !!!!
+ }
+ else
+ {
+ // Do something here !!!!
+ }
}
if (response instanceof HTTPRedirectionResponse)
@@ -517,11 +519,11 @@
private PortletInvocationResponse deliverEvent(
PortletControllerContext context,
- Portlet portlet,
- StateResponse.Event event,
+ Event event,
PageNavigationalState pageNS,
- List<Cookie> requestCookies)
+ List<Cookie> requestCookies) throws PortletInvokerException
{
+ Portlet portlet = context.getPortlet(event.getPortletContext().getId());
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(portlet.getContext().getId());
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-31 10:32:11 UTC (rev 9680)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContext.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -51,4 +52,6 @@
Collection<Portlet> getPortlets() throws PortletInvokerException;
+ EventControllerContext getEventControllerContext();
+
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-31 10:32:11 UTC (rev 9680)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -40,6 +40,8 @@
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.web.WebRequest;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
+import org.jboss.portal.portlet.test.event.EventControllerContext;
+import org.jboss.portal.portlet.test.event.EventControllerContextImpl;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -76,6 +78,9 @@
/** . */
private final PortletInvoker invoker;
+ /** . */
+ private final EventControllerContext eventControllerContext;
+
public PortletControllerContextImpl(
HttpServletRequest req,
HttpServletResponse resp,
@@ -230,6 +235,7 @@
this.resp = resp;
this.servletContext = servletContext;
this.invoker = invoker;
+ this.eventControllerContext = new EventControllerContextImpl(invoker);
}
public PortletController.ControllerRequest getRequest()
@@ -266,4 +272,9 @@
{
return invoker.getPortlets();
}
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/Event.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/Event.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/Event.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * 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.event;
+
+import org.jboss.portal.portlet.PortletContext;
+
+import javax.xml.namespace.QName;
+import java.io.Serializable;
+
+/**
+ * An event associated with a portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class Event
+{
+
+ /** . */
+ private final QName name;
+
+ /** . */
+ private final Serializable payload;
+
+ /** . */
+ private final PortletContext portletContext;
+
+ public Event(QName name, Serializable payload, PortletContext portletContext)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.payload = payload;
+ this.portletContext = portletContext;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public Serializable getPayload()
+ {
+ return payload;
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContext.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContext.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.event;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface EventControllerContext
+{
+
+ /**
+ * Obtain a list of consumed event for a produced event.
+ *
+ * @param producedEvent the produced event
+ * @return the list of event to be consumed
+ */
+ List<Event> getConsumedEvents(Event producedEvent);
+
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContextImpl.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/event/EventControllerContextImpl.java 2008-01-31 11:14:00 UTC (rev 9681)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.event;
+
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EventControllerContextImpl implements EventControllerContext
+{
+
+ /** . */
+ private PortletInvoker invoker;
+
+ public EventControllerContextImpl(PortletInvoker invoker)
+ {
+ this.invoker = invoker;
+ }
+
+ public List<Event> getConsumedEvents(Event producedEvent)
+ {
+ try
+ {
+ ArrayList<Event> consumedEvents = new ArrayList<Event>();
+ for (Portlet portlet : invoker.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+ if (portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
+ {
+ Event consumedEvent = new Event(producedEvent.getName(), producedEvent.getPayload(), portlet.getContext());
+ consumedEvents.add(consumedEvent);
+ }
+ }
+ return consumedEvents;
+ }
+ catch (PortletInvokerException e)
+ {
+ System.out.println("e = " + e);
+
+ //
+ return Collections.emptyList();
+ }
+ }
+}
16 years, 2 months