Author: julien(a)jboss.com
Date: 2008-01-21 16:32:53 -0500 (Mon, 21 Jan 2008)
New Revision: 9548
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java
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
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.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/RenderInvocation.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java
Log:
start to implement resource serving
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/Cacheability.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum Cacheability
+{
+
+ FULL, PORTLET, PAGE
+
+}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ContainerURL.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ContainerURL
+{
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/PortletURL.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -31,25 +31,26 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5448 $
*/
-public interface PortletURL
+public interface PortletURL extends ContainerURL
{
/**
- * The mode that may be null.
+ * Returns the mode that may be null.
*
* @return the mode
*/
Mode getMode();
/**
- * The window state that may be null.
+ * Returns the window state that may be null.
*
* @return the window state
*/
WindowState getWindowState();
/**
- *
- * @return
+ * Returns the public navigational state changes.
+ *
+ * @return the public navigational state changes
*/
Map<String, String[]> getPublicNavigationalStateChanges();
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ResourceURL.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ResourceURL extends ContainerURL
+{
+
+ String getId();
+
+ /**
+ * Return the resource state.
+ *
+ * @return the resource state
+ */
+ StateString getResourceState();
+
+ /**
+ * Returs the resource cacheability.
+ *
+ * @return the resource cacheability
+ */
+ Cacheability getCacheability();
+}
Modified:
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/ModesInterceptor.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -48,7 +48,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- if ((invocation.getPortletContext()).getMode() == null)
+ if ((invocation.getContext()).getMode() == null)
{
throw new InvocationException("No mode has been provided");
}
@@ -67,7 +67,7 @@
protected Set<Mode> getModes(PortletInvocation invocation)
{
// Get content type
- ContentInfo si = invocation.getPortletContext().getMarkupInfo();
+ ContentInfo si = invocation.getContext().getMarkupInfo();
String contentType = si.getContentType().toString();
// Get the modes for this content type
Modified:
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/aspects/portlet/WindowStatesInterceptor.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -41,7 +41,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception,
InvocationException
{
- if (invocation.getPortletContext().getWindowState() == null)
+ if (invocation.getContext().getWindowState() == null)
{
throw new InvocationException("No window state has been provided");
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/PortletRequestEncoder.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -68,24 +68,6 @@
this(new ParameterMap());
}
- public void encode(PortletURL portletURL) throws IllegalArgumentException
- {
- if (portletURL instanceof RenderURL)
- {
- RenderURL renderURL = (RenderURL)portletURL;
- encodeRender(renderURL.getNavigationalState(), renderURL.getMode(),
renderURL.getWindowState());
- }
- else if (portletURL instanceof ActionURL)
- {
- ActionURL actionURL = (ActionURL)portletURL;
- encodeAction(actionURL.getNavigationalState(), actionURL.getInteractionState(),
actionURL.getMode(), actionURL.getWindowState());
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
-
public void encodeAction(
StateString navigationalState,
StateString interactionState,
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletAPIFactoryImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -25,12 +25,15 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
/**
@@ -68,4 +71,14 @@
{
return new RenderResponseImpl(invocation, renderRequest);
}
+
+ public ResourceRequestImpl createResourceRequest(ResourceInvocation invocation)
+ {
+ return new ResourceRequestImpl(invocation);
+ }
+
+ public ResourceResponseImpl createResourceResponse(ResourceInvocation invocation,
ResourceRequestImpl renderRequest)
+ {
+ return new ResourceResponseImpl(invocation, renderRequest);
+ }
}
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.spi.PortletAPIFactory;
import org.jboss.portal.portlet.impl.info.ContainerPortletInfo;
import org.jboss.portal.portlet.impl.info.ContainerPreferencesInfo;
@@ -44,6 +46,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.SecurityErrorResponse;
@@ -57,6 +60,7 @@
import javax.portlet.PreferencesValidator;
import javax.portlet.UnavailableException;
import javax.portlet.EventPortlet;
+import javax.portlet.ResourceServingPortlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Set;
@@ -401,16 +405,16 @@
protected PortletInvocationResponse invokeAction(ActionInvocation invocation) throws
IOException, PortletException
{
PortletAPIFactory factory = application.getPortletAPIFactory();
- ActionRequestImpl areq = factory.createActionRequest(invocation);
- ActionResponseImpl aresp = factory.createActionResponse(invocation, areq);
+ ActionRequestImpl req = factory.createActionRequest(invocation);
+ ActionResponseImpl resp = factory.createActionResponse(invocation, req);
HttpServletRequest dreq = invocation.getDispatchedRequest();
try
{
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, areq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, aresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
- portlet.processAction(areq, aresp);
+ portlet.processAction(req, resp);
}
finally
{
@@ -420,22 +424,22 @@
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
- return aresp.getResponse();
+ return resp.getResponse();
}
protected PortletInvocationResponse invokeRender(RenderInvocation invocation) throws
IOException, PortletException
{
PortletAPIFactory factory = application.getPortletAPIFactory();
- RenderRequestImpl rreq = factory.createRenderRequest(invocation);
- RenderResponseImpl rresp = factory.createRenderResponse(invocation, rreq);
+ RenderRequestImpl req = factory.createRenderRequest(invocation);
+ RenderResponseImpl resp = factory.createRenderResponse(invocation, req);
HttpServletRequest dreq = invocation.getDispatchedRequest();
try
{
dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, rreq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, rresp);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
- portlet.render(rreq, rresp);
+ portlet.render(req, resp);
}
finally
{
@@ -444,12 +448,12 @@
dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
}
- return rresp.getResult();
+ return resp.getResponse();
}
protected PortletInvocationResponse invokeEvent(EventInvocation invocation) throws
IOException, PortletException
{
- // Todo something clever
+ // Todo something clever if CCE occues
EventPortlet eventPortlet = (EventPortlet)portlet;
//
@@ -474,4 +478,34 @@
}
return eresp.getResponse();
}
+
+ protected PortletInvocationResponse invokeResource(ResourceInvocation invocation)
throws IOException, PortletException
+ {
+ // Todo something clever if CCE occues
+ ResourceServingPortlet eventPortlet = (ResourceServingPortlet)portlet;
+
+ //
+ PortletAPIFactory factory = application.getPortletAPIFactory();
+ ResourceRequestImpl req = factory.createResourceRequest(invocation);
+ ResourceResponseImpl resp = factory.createResourceResponse(invocation, req);
+ HttpServletRequest dreq = invocation.getDispatchedRequest();
+ try
+ {
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, req);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, resp);
+ dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
+ eventPortlet.serveResource(req, resp);
+ }
+ finally
+ {
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
+ }
+
+ //
+ return resp.getResponse();
+ }
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/PortletRequestParameterMap.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,14 +23,16 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.spi.EventContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.spi.ActionContext;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.info.NavigationInfo;
import java.util.Iterator;
-import java.util.Map;
/**
* The main responsibility of this class is to combine the different parameter sources
(private navigational state,
@@ -42,8 +44,89 @@
public class PortletRequestParameterMap
{
- private static final ParameterMap.AccessMode COPY_MODE =
ParameterMap.AccessMode.get(true, true);
+ /** . */
+ protected static final ParameterMap.AccessMode COPY_MODE =
ParameterMap.AccessMode.get(true, true);
+ /**
+ * Factory method that will chose the right builder according to the context argument
type.
+ */
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo,
PortletInvocationContext context)
+ {
+ if (context instanceof EventContext)
+ {
+ return create(navigationInfo, (EventContext)context);
+ }
+ else if (context instanceof ActionContext)
+ {
+ return create(navigationInfo, (ActionContext)context);
+ }
+ else if (context instanceof RenderContext)
+ {
+ return create(navigationInfo, (RenderContext)context);
+ }
+ else
+ {
+ return ResourceRequestParameterMap.create(navigationInfo,
(ResourceInvocationContext)context);
+ }
+ }
+
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo,
EventContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo,
context.getPublicNavigationalState());
+
+ // Get render parameters
+ ParameterMap privateParameters =
safeBuildParameters(context.getNavigationalState());
+
+ // Build combined map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters,
publicParameters);
+ }
+
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo,
RenderContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo,
context.getPublicNavigationalState());
+
+ // Get render parameters
+ ParameterMap privateParameters =
safeBuildParameters(context.getNavigationalState());
+
+ // Build combined map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters,
publicParameters);
+ }
+
+ /**
+ * - interaction parameter : always
+ * - form parameter : if it is a POST with the content type set to application/...
+ * - public render parameter : optionally sent by the consumer
+
+ * - getParameterMap() : the interaction parameter + form parameters if any + public
render parameter
+ * - getPrivateParameterMap() : the interaction parameter + form parameter
+ * - getPublicParameterMap() : public render parameter
+ */
+ public static PortletRequestParameterMap create(NavigationInfo navigationInfo,
ActionContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo,
context.getPublicNavigationalState());
+
+ // The private parameters
+ ParameterMap privateParameters =
safeBuildParameters(context.getInteractionState());
+
+ // Combine form if we have one
+ privateParameters = safeCombine(privateParameters, context.getForm());
+
+ // Combine to get shared map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new PortletRequestParameterMap(parameters, privateParameters,
publicParameters);
+ }
+
/** . */
protected final ParameterMap parameters;
@@ -53,16 +136,51 @@
/** . */
protected final ParameterMap publicParameters;
- public PortletRequestParameterMap(NavigationInfo navigationInfo,
PortletInvocationContext context)
+ protected PortletRequestParameterMap(
+ ParameterMap parameters,
+ ParameterMap privateParameters,
+ ParameterMap publicParameters)
{
- // Build public parameters
- ParameterMap publicParameters = null;
+ if (privateParameters != null)
+ {
+ privateParameters = privateParameters.as(COPY_MODE);
+ }
+ if (publicParameters != null)
+ {
+ publicParameters = publicParameters.as(COPY_MODE);
+ }
+ if (parameters != null)
+ {
+ parameters = parameters.as(COPY_MODE);
+ }
//
- if (context.getPublicNavigationalState() != null)
+ this.parameters = parameters;
+ this.privateParameters = privateParameters;
+ this.publicParameters = publicParameters;
+ }
+
+ public ParameterMap getParameters()
+ {
+ return parameters;
+ }
+
+ public ParameterMap getPrivateParameters()
+ {
+ return privateParameters;
+ }
+
+ public ParameterMap getPublicParameters()
+ {
+ return publicParameters;
+ }
+
+ protected static ParameterMap safeBuildPublicParameters(NavigationInfo navigationInfo,
ParameterMap publicNavigationalParameters)
+ {
+ if (publicNavigationalParameters != null)
{
// Clone the public navigational state with the copy mode
- publicParameters = ParameterMap.clone(context.getPublicNavigationalState());
+ ParameterMap publicParameters =
ParameterMap.clone(publicNavigationalParameters);
// Remove any parameter that would have been sent by the producer by mistake
for (Iterator<String> i = publicParameters.keySet().iterator();
i.hasNext();)
@@ -73,153 +191,53 @@
i.remove();
}
}
+
+ //
+ return publicParameters;
}
+ else
+ {
+ return null;
+ }
+ }
- //
- if (context instanceof ActionContext)
+ protected static ParameterMap safeBuildParameters(StateString stateString)
+ {
+ if (stateString != null)
{
- ActionContext actionContext = (ActionContext)context;
+ return ParametersStateString.create(stateString).getParameters();
+ }
+ else
+ {
+ return null;
+ }
+ }
- // The private parameters
- ParameterMap privateParameters = null;
-
- // Get the possibly null interaction state
- StateString interactionState = actionContext.getInteractionState();
- if (interactionState != null)
+ protected static ParameterMap safeCombine(ParameterMap privateParameters, ParameterMap
publicParameters)
+ {
+ if (publicParameters != null)
+ {
+ if (privateParameters != null)
{
- privateParameters =
ParametersStateString.create(interactionState).getParameters();
+ ParameterMap parameters = ParameterMap.clone(privateParameters);
+ parameters.append(publicParameters);
+ return parameters;
}
-
- // Combine form if we have one
- ParameterMap form = actionContext.getForm();
- if (form != null)
- {
- if (privateParameters == null)
- {
- privateParameters = form;
- }
- else
- {
- privateParameters.append(form);
- }
- }
-
- //
- ParameterMap parameters;
- if (publicParameters != null)
- {
- if (privateParameters != null)
- {
- parameters = ParameterMap.clone(privateParameters);
- parameters.append(publicParameters);
- }
- else
- {
- parameters = publicParameters;
- }
- }
else
{
- if (privateParameters != null)
- {
- parameters = privateParameters;
- }
- else
- {
- parameters = null;
- }
+ return publicParameters;
}
-
- // Use with access mode that will prevent external updates to the map
- if (privateParameters != null)
- {
- privateParameters = privateParameters.as(COPY_MODE);
- }
- if (publicParameters != null)
- {
- publicParameters = publicParameters.as(COPY_MODE);
- }
- if (parameters != null)
- {
- parameters = parameters.as(COPY_MODE);
- }
-
- //
- this.privateParameters = privateParameters;
- this.publicParameters = publicParameters;
- this.parameters = parameters;
}
else
{
- // Get the possibly null navigational state
- StateString navigationalState = context.getNavigationalState();
-
- //
- ParameterMap privateParameters = null;
- if (navigationalState != null)
+ if (privateParameters != null)
{
- privateParameters =
ParametersStateString.create(navigationalState).getParameters();
+ return privateParameters;
}
-
- // Build combined map
- ParameterMap parameters;
- if (publicParameters != null)
- {
- if (privateParameters != null)
- {
- parameters = ParameterMap.clone(privateParameters);
- parameters.append(publicParameters);
- }
- else
- {
- parameters = publicParameters;
- }
- }
else
{
- if (privateParameters != null)
- {
- parameters = privateParameters;
- }
- else
- {
- parameters = null;
- }
+ return null;
}
-
- // Use with access mode that will prevent external updates to the map
- if (privateParameters != null)
- {
- privateParameters = privateParameters.as(COPY_MODE);
- }
- if (publicParameters != null)
- {
- publicParameters = publicParameters.as(COPY_MODE);
- }
- if (parameters != null)
- {
- parameters = parameters.as(COPY_MODE);
- }
-
- //
- this.privateParameters = privateParameters;
- this.publicParameters = publicParameters;
- this.parameters = parameters;
}
}
-
- public ParameterMap getParameters()
- {
- return parameters;
- }
-
- public ParameterMap getPrivateParameters()
- {
- return privateParameters;
- }
-
- public ParameterMap getPublicParameters()
- {
- return publicParameters;
- }
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/ResourceRequestParameterMap.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceRequestParameterMap extends PortletRequestParameterMap
+{
+
+ /** . */
+ protected final ParameterMap privateRenderParameters;
+
+ protected ResourceRequestParameterMap(
+ ParameterMap parameters,
+ ParameterMap privateParameters,
+ ParameterMap publicParameters,
+ ParameterMap privateRenderParameters)
+ {
+ super(parameters, privateParameters, publicParameters);
+
+ //
+ if (privateRenderParameters != null)
+ {
+ privateRenderParameters = privateRenderParameters.as(COPY_MODE);
+ }
+
+ //
+ this.privateRenderParameters = privateRenderParameters;
+ }
+
+ public ParameterMap getPrivateRenderParameters()
+ {
+ return privateRenderParameters;
+ }
+
+ /**
+ * - resource parameter : always
+ * - form parameter : if it is a POST with the content type set to application/...
+ * - render parameter : depends on the cacheability of the request
+ * - public render parameter : optionally sent by the consumer
+
+ * - getParameterMap() : the resource parameter + form parameters if any + render
parameter + public render parameter
+ * - getPrivateParameterMap() : the resource parameter + form parameter
+ * - getPublicParameterMap() : public render parameter
+ * - getPrivateRenderParameterMap() : render parameter
+ */
+ public static ResourceRequestParameterMap create(NavigationInfo navigationInfo,
ResourceInvocationContext context)
+ {
+ // Build public parameters
+ ParameterMap publicParameters = safeBuildPublicParameters(navigationInfo,
context.getPublicNavigationalState());
+
+ // Combine private render parameters if any
+ ParameterMap privateRenderParameters =
safeBuildParameters(context.getNavigationalState());
+
+ // The private parameters
+ ParameterMap privateParameters = safeBuildParameters(context.getResourceState());
+
+ // Combine form if we have one
+ privateParameters = safeCombine(privateParameters, context.getForm());
+
+ // Combien with private render parameters
+ privateParameters = safeCombine(privateParameters, privateRenderParameters);
+
+ // Combine to get shared map
+ ParameterMap parameters = safeCombine(privateParameters, publicParameters);
+
+ //
+ return new ResourceRequestParameterMap(parameters, privateParameters,
publicParameters, privateRenderParameters);
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/BaseURLImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,18 +23,11 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
-import org.jboss.portal.Mode;
import org.jboss.portal.common.NotYetImplemented;
import javax.portlet.BaseURL;
-import javax.portlet.WindowState;
-import javax.portlet.PortletMode;
import javax.portlet.PortletSecurityException;
import java.util.Map;
import java.io.Writer;
@@ -47,52 +40,20 @@
public abstract class BaseURLImpl implements BaseURL
{
- public enum Type
- {
- ACTION, RENDER
- }
+ /** . */
+ protected final PortletInvocation inv;
- public static PortletURLImpl createActionURL(PortletInvocation invocation,
PortletRequestImpl preq)
- {
- return new PortletURLImpl(invocation, preq, Type.ACTION);
- }
-
- public static PortletURLImpl createRenderURL(PortletInvocation invocation,
PortletRequestImpl preq)
- {
- return new PortletURLImpl(invocation, preq, Type.RENDER);
- }
-
/** . */
- protected PortletInvocation inv;
+ protected final PortletRequestImpl preq;
/** . */
- protected PortletRequestImpl preq;
+ protected final InternalContainerURL url;
/** . */
protected Boolean secure;
- /** . */
- protected InternalPortletURL url;
-
- protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type
type)
+ protected BaseURLImpl(PortletInvocation invocation, PortletRequestImpl preq,
InternalContainerURL url)
{
- PortletParameterMap parameterMap = new PortletParameterMap(preq.navigationInfo);
-
- //
- InternalPortletURL url;
- switch (type)
- {
- case ACTION:
- url = new InternalActionURL(parameterMap);
- break;
- case RENDER:
- url = new InternalRenderURL(parameterMap);
- break;
- default:
- throw new AssertionError();
- }
-
- //
this.inv = invocation;
this.preq = preq;
this.url = url;
@@ -146,82 +107,19 @@
public String toString()
{
- PortletInvocationContext responseContext = inv.getPortletContext();
+ PortletInvocationContext responseContext = inv.getContext();
return responseContext.renderURL(url, secure, null, true);
}
- protected abstract class InternalPortletURL implements
org.jboss.portal.portlet.PortletURL
+ protected static abstract class InternalContainerURL implements
org.jboss.portal.portlet.ContainerURL
{
/** . */
- protected WindowState windowState;
-
- /** . */
- protected PortletMode portletMode;
-
- /** . */
protected final PortletParameterMap parameters;
- protected InternalPortletURL(PortletParameterMap parameters)
+ protected InternalContainerURL(PortletParameterMap parameters)
{
this.parameters = parameters;
}
-
- public Mode getMode()
- {
- if (portletMode != null)
- {
- return Mode.create(portletMode.toString());
- }
- return null;
- }
-
- public org.jboss.portal.WindowState getWindowState()
- {
- if (windowState != null)
- {
- return org.jboss.portal.WindowState.create(windowState.toString());
- }
- return null;
- }
-
- public Map<String, String[]> getPublicNavigationalStateChanges()
- {
- return parameters.getPublicMapSnapshot();
- }
}
-
- protected class InternalActionURL extends InternalPortletURL implements ActionURL
- {
-
- private InternalActionURL(PortletParameterMap parameters)
- {
- super(parameters);
- }
-
- public StateString getInteractionState()
- {
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
- }
-
- /** The portlet container does not need to have the navigational state provided.
*/
- public StateString getNavigationalState()
- {
- return BaseURLImpl.this.inv.getPortletContext().getNavigationalState();
- }
- }
-
- protected class InternalRenderURL extends InternalPortletURL implements RenderURL
- {
-
- private InternalRenderURL(PortletParameterMap parameters)
- {
- super(parameters);
- }
-
- public StateString getNavigationalState()
- {
- return ParametersStateString.create(parameters.getPrivateMapSnapshot());
- }
- }
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventRequestImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -47,7 +47,7 @@
{
if (event == null)
{
- event = new EventImpl((EventContext)invocation.getPortletContext());
+ event = new EventImpl((EventContext)invocation.getContext());
}
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/EventResponseImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -54,7 +54,7 @@
}
//
- PortletInvocationContext context = invocation.getPortletContext();
+ PortletInvocationContext context = invocation.getContext();
//
WantUpdate update = wantUpdate();
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/MimeResponseImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -25,19 +25,15 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ContentInfo;
import org.jboss.portal.common.NotYetImplemented;
-import org.w3c.dom.Element;
-import org.w3c.dom.DOMException;
import javax.portlet.MimeResponse;
import javax.portlet.PortletURL;
import javax.portlet.ResourceURL;
import javax.portlet.CacheControl;
import javax.activation.MimeTypeParseException;
-import javax.servlet.http.Cookie;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.OutputStream;
@@ -65,7 +61,7 @@
this.result = new FragmentResponse();
}
- public PortletInvocationResponse getResult()
+ public PortletInvocationResponse getResponse()
{
return result;
}
@@ -90,7 +86,7 @@
MediaType requestedMediaType = MediaType.parseMimeType(contentType);
// Get the response media type
- ContentInfo info = invocation.getPortletContext().getMarkupInfo();
+ ContentInfo info = invocation.getContext().getMarkupInfo();
MediaType responseMediaType = info.getContentType();
// Check if the requested media type is allowed as a subtype of the main
response
@@ -122,17 +118,17 @@
public PortletURL createRenderURL()
{
- return BaseURLImpl.createRenderURL(invocation, preq);
+ return PortletURLImpl.createRenderURL(invocation, preq);
}
public PortletURL createActionURL()
{
- return BaseURLImpl.createActionURL(invocation, preq);
+ return PortletURLImpl.createActionURL(invocation, preq);
}
public String getCharacterEncoding()
{
- return invocation.getPortletContext().getMarkupInfo().getCharset();
+ return invocation.getContext().getMarkupInfo().getCharset();
}
public Locale getLocale()
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -118,7 +118,7 @@
this.attributes = new PortletRequestAttributes(container, userContext);
this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator,
mode);
this.navigationInfo = navigationInfo;
- this.requestParameterMap = new PortletRequestParameterMap(navigationInfo,
invocation.getPortletContext());
+ this.requestParameterMap = PortletRequestParameterMap.create(navigationInfo,
invocation.getContext());
}
// PLT.11.1.1
@@ -176,13 +176,13 @@
public WindowState getWindowState()
{
- String s = invocation.getPortletContext().getWindowState().toString();
+ String s = invocation.getContext().getWindowState().toString();
return PortletUtils.decodeWindowState(s);
}
public PortletMode getPortletMode()
{
- String s = invocation.getPortletContext().getMode().toString();
+ String s = invocation.getContext().getMode().toString();
return PortletUtils.decodePortletMode(s);
}
@@ -342,7 +342,7 @@
public String getResponseContentType()
{
- return invocation.getPortletContext().getMarkupInfo().getContentType().toString();
+ return invocation.getContext().getMarkupInfo().getContentType().toString();
}
public Enumeration<String> getResponseContentTypes()
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168.api;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.common.NotYetImplemented;
@@ -56,13 +57,15 @@
this.preq = preq;
}
+ public abstract PortletInvocationResponse getResponse();
+
public String encodeURL(String url)
{
if (url == null)
{
throw new IllegalArgumentException("URL must not be null");
}
- return invocation.getPortletContext().encodeResourceURL(url);
+ return invocation.getContext().encodeResourceURL(url);
}
public void addProperty(String key, String value) throws IllegalArgumentException
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -24,12 +24,19 @@
import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.Mode;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.portlet.WindowStateException;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -38,11 +45,30 @@
public class PortletURLImpl extends BaseURLImpl implements PortletURL
{
- protected PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq, Type
type)
+ public static PortletURLImpl createActionURL(PortletInvocation invocation,
PortletRequestImpl preq)
{
- super(invocation, preq, type);
+ StateString navigationalState = invocation.getContext().getNavigationalState();
+ InternalActionURL url = new InternalActionURL(new
PortletParameterMap(preq.navigationInfo), navigationalState);
+ return new PortletURLImpl(invocation, preq, url);
}
+ public static PortletURLImpl createRenderURL(PortletInvocation invocation,
PortletRequestImpl preq)
+ {
+ InternalRenderURL url = new InternalRenderURL(new
PortletParameterMap(preq.navigationInfo));
+ return new PortletURLImpl(invocation, preq, url);
+ }
+
+ /** . */
+ private final InternalPortletURL url;
+
+ private PortletURLImpl(PortletInvocation invocation, PortletRequestImpl preq,
InternalPortletURL url)
+ {
+ super(invocation, preq, url);
+
+ //
+ this.url = url;
+ }
+
public void setWindowState(WindowState windowState) throws WindowStateException
{
if (!preq.isWindowStateAllowed(windowState))
@@ -87,4 +113,81 @@
{
url.parameters.removePublicParameterValue(name);
}
+
+ private static abstract class InternalPortletURL extends InternalContainerURL
implements org.jboss.portal.portlet.PortletURL
+ {
+
+ /** . */
+ protected WindowState windowState;
+
+ /** . */
+ protected PortletMode portletMode;
+
+ protected InternalPortletURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public Mode getMode()
+ {
+ if (portletMode != null)
+ {
+ return Mode.create(portletMode.toString());
+ }
+ return null;
+ }
+
+ public org.jboss.portal.WindowState getWindowState()
+ {
+ if (windowState != null)
+ {
+ return org.jboss.portal.WindowState.create(windowState.toString());
+ }
+ return null;
+ }
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
+ {
+ return parameters.getPublicMapSnapshot();
+ }
+ }
+
+ private static class InternalActionURL extends InternalPortletURL implements
ActionURL
+ {
+
+ /** . */
+ private final StateString navigationalState;
+
+ private InternalActionURL(PortletParameterMap parameters, StateString
navigationalState)
+ {
+ super(parameters);
+
+ //
+ this.navigationalState = navigationalState;
+ }
+
+ public StateString getInteractionState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+ }
+
+ private static class InternalRenderURL extends InternalPortletURL implements
RenderURL
+ {
+
+ private InternalRenderURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public StateString getNavigationalState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+ }
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceRequestImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.impl.jsr168.ResourceRequestParameterMap;
+
+import javax.portlet.ResourceRequest;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceRequestImpl extends ClientDataRequestImpl implements
ResourceRequest
+{
+
+ /** . */
+ private final ResourceInvocationContext resourceContext;
+
+ public ResourceRequestImpl(ResourceInvocation invocation)
+ {
+ super(invocation);
+
+ //
+ this.resourceContext = invocation.getContext();
+ }
+
+ public String getETag()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getResourceID()
+ {
+ return resourceContext.getResourceId();
+ }
+
+ public Map<String, String[]> getPrivateRenderParameterMap()
+ {
+ return
((ResourceRequestParameterMap)requestParameterMap).getPrivateRenderParameters();
+ }
+
+ public String getCacheability()
+ {
+ return ResourceURLImpl.toJSR168(resourceContext.getCacheability());
+ }
+}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceResponseImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+
+import javax.portlet.ResourceResponse;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceResponseImpl extends MimeResponseImpl implements ResourceResponse
+{
+
+ public ResourceResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
+ {
+ super(invocation, preq);
+ }
+
+ public void setLocale(Locale locale)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCharacterEncoding(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContentLength(int i)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/ResourceURLImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,179 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
+
+import javax.portlet.ResourceURL;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceURLImpl extends BaseURLImpl implements ResourceURL
+{
+
+ /** . */
+ private static final Map<String, Cacheability> jsr168ToType = new
HashMap<String, Cacheability>();
+
+ /** . */
+ private static final Map<Cacheability, String> typetoJSR168 = new
HashMap<Cacheability, String>();
+
+ static
+ {
+ jsr168ToType.put(ResourceURL.FULL, Cacheability.FULL);
+ jsr168ToType.put(ResourceURL.PAGE, Cacheability.PAGE);
+ jsr168ToType.put(ResourceURL.PORTLET, Cacheability.PORTLET);
+
+ //
+ typetoJSR168.put(Cacheability.FULL, ResourceURL.FULL);
+ typetoJSR168.put(Cacheability.PAGE, ResourceURL.PAGE);
+ typetoJSR168.put(Cacheability.PORTLET, ResourceURL.PORTLET);
+ }
+
+ public static String toJSR168(Cacheability cacheability)
+ {
+ return typetoJSR168.get(cacheability);
+ }
+
+ /** . */
+ private final InternalResourceURL url;
+
+ private ResourceURLImpl(
+ PortletInvocation invocation,
+ PortletRequestImpl preq,
+ InternalResourceURL url)
+ {
+ super(invocation, preq, url);
+
+ //
+ this.url = url;
+
+ //
+ if (invocation instanceof ResourceInvocation)
+ {
+ url.constraint =
((ResourceInvocation)invocation).getContext().getCacheability();
+ }
+ }
+
+ public void setResourceID(String resourceID)
+ {
+ if (resourceID != null)
+ {
+ url.id = resourceID;
+ }
+ }
+
+ public String getCacheability()
+ {
+ Cacheability cacheability = url.cacheability;
+
+ //
+ if (cacheability == null)
+ {
+ cacheability = url.constraint != null ? url.constraint : Cacheability.PAGE;
+ }
+
+ //
+ return typetoJSR168.get(cacheability);
+ }
+
+ public void setCacheability(String s)
+ {
+ Cacheability cacheability = jsr168ToType.get(s);
+
+ //
+ if (cacheability != null)
+ {
+ if (url.constraint == null)
+ {
+ url.cacheability = cacheability;
+ }
+ else
+ {
+ switch (url.constraint)
+ {
+ case FULL:
+ if (cacheability != Cacheability.FULL)
+ {
+ throw new IllegalStateException();
+ }
+ break;
+ case PORTLET:
+ if (cacheability == Cacheability.PAGE)
+ {
+ throw new IllegalStateException();
+ }
+ break;
+ }
+ url.cacheability = cacheability;
+ }
+ }
+ }
+
+ public static ResourceURLImpl createResourceURL(PortletInvocation invocation,
PortletRequestImpl preq)
+ {
+ InternalResourceURL url = new InternalResourceURL(new
PortletParameterMap(preq.navigationInfo));
+ return new ResourceURLImpl(invocation, preq, url);
+ }
+
+ private static class InternalResourceURL extends InternalContainerURL implements
org.jboss.portal.portlet.ResourceURL
+ {
+
+ /** . */
+ private String id;
+
+ /** The cacheability constraining the url cacheability. */
+ private Cacheability constraint;
+
+ /** . */
+ private Cacheability cacheability;
+
+ private InternalResourceURL(PortletParameterMap parameters)
+ {
+ super(parameters);
+ }
+
+ public StateString getResourceState()
+ {
+ return ParametersStateString.create(parameters.getPrivateMapSnapshot());
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Cacheability getCacheability()
+ {
+ return cacheability;
+ }
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/api/StateAwareResponseImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -26,6 +26,7 @@
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
import org.jboss.portal.portlet.invocation.response.StateResponse;
import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.PortletParameterMap;
@@ -82,7 +83,7 @@
super(invocation, preq);
}
- public StateResponse getResponse()
+ public PortletInvocationResponse getResponse()
{
Decision decision = wantRedirect;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/spi/PortletAPIFactory.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -25,12 +25,15 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventRequestImpl;
import org.jboss.portal.portlet.impl.jsr168.api.EventResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ResourceResponseImpl;
/**
* Factory for portlet API implementation.
@@ -63,4 +66,12 @@
/**
*/
RenderResponseImpl createRenderResponse(RenderInvocation invocation, RenderRequestImpl
renderRequest);
+
+ /**
+ */
+ ResourceRequestImpl createResourceRequest(ResourceInvocation invocation);
+
+ /**
+ */
+ ResourceResponseImpl createResourceResponse(ResourceInvocation invocation,
ResourceRequestImpl renderRequest);
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/jsr168/taglib/GenerateURLTag.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -22,8 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.impl.jsr168.taglib;
-import org.jboss.portal.portlet.impl.jsr168.api.BaseURLImpl;
import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletURLImpl;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
@@ -191,11 +191,11 @@
// Create the URL
if ("action".equals(getTypeValue()))
{
- return BaseURLImpl.createActionURL(getInvocation(), preq);
+ return PortletURLImpl.createActionURL(getInvocation(), preq);
}
else if ("render".equals(getTypeValue()))
{
- return BaseURLImpl.createRenderURL(getInvocation(), preq);
+ return PortletURLImpl.createRenderURL(getInvocation(), preq);
}
else
{
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/spi/AbstractResourceContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.spi;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class AbstractResourceContext extends AbstractPortletInvocationContext
implements ResourceInvocationContext
+{
+
+ /** . */
+ private final String resourceId;
+
+ /** . */
+ private final Cacheability cacheability;
+
+ /** . */
+ private final StateString resourceState;
+
+ /** . */
+ private final ParameterMap form;
+
+ public AbstractResourceContext(
+ String resourceId,
+ Cacheability cacheability,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ ParameterMap publicNavigationalState,
+ StateString resourceState,
+ ParameterMap form,
+ MarkupInfo markupInfo)
+ {
+ super(mode, windowState, navigationalState, publicNavigationalState, markupInfo);
+
+ //
+ this.resourceId = resourceId;
+ this.cacheability = cacheability;
+ this.resourceState = resourceState;
+ this.form = form;
+ }
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ public Cacheability getCacheability()
+ {
+ return cacheability;
+ }
+
+ public StateString getResourceState()
+ {
+ return resourceState;
+ }
+
+ public ParameterMap getForm()
+ {
+ return form;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ActionInvocation.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class ActionInvocation extends PortletInvocation
{
- public ActionInvocation(ActionContext ctx)
+
+ /** . */
+ private final ActionContext ctx;
+
+ public ActionInvocation(ActionContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public ActionContext getContext()
+ {
+ return ctx;
+ }
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/EventInvocation.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class EventInvocation extends PortletInvocation
{
+
+ /** . */
+ private final EventContext ctx;
+
public EventInvocation(EventContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public EventContext getContext()
+ {
+ return ctx;
+ }
}
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/PortletInvocation.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -117,16 +117,11 @@
this.ctx = ctx;
}
- public InvocationContext getContext()
+ public PortletInvocationContext getContext()
{
return ctx;
}
- public PortletInvocationContext getPortletContext()
- {
- return ctx;
- }
-
public PortletContext getTarget()
{
return target;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/RenderInvocation.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -30,8 +30,20 @@
*/
public class RenderInvocation extends PortletInvocation
{
- public RenderInvocation(RenderContext ctx)
+
+ /** . */
+ private final RenderContext ctx;
+
+ public RenderInvocation(RenderContext ctx) throws IllegalArgumentException
{
super(ctx);
+
+ //
+ this.ctx = ctx;
}
+
+ public RenderContext getContext()
+ {
+ return ctx;
+ }
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/invocation/ResourceInvocation.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.invocation;
+
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ResourceInvocation extends PortletInvocation
+{
+
+ /** . */
+ private final ResourceInvocationContext ctx;
+
+ public ResourceInvocation(ResourceInvocationContext ctx) throws
IllegalArgumentException
+ {
+ super(ctx);
+
+ //
+ this.ctx = ctx;
+ }
+
+ public ResourceInvocationContext getContext()
+ {
+ return ctx;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/PortletInvocationContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -29,6 +29,7 @@
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
/**
* Contract that defines what input/services the caller of a portlet container must
provide.
@@ -84,14 +85,16 @@
String encodeResourceURL(String url) throws IllegalArgumentException;
/**
- * @param portletURL the portlet url
+ * Renders a container URL.
+ *
+ * @param containerURL the portlet url
* @param wantSecure if the url should be secure
* @param wantAuthenticated if the url should be authenticated
* @param relative if the url should be relative
- * @return the url
+ * @return the rendered url
*/
String renderURL(
- PortletURL portletURL,
+ ContainerURL containerURL,
Boolean wantSecure,
Boolean wantAuthenticated,
boolean relative);
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/spi/ResourceInvocationContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.spi;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ResourceInvocationContext extends PortletInvocationContext
+{
+
+ /**
+ * Returns the resource id. It may be a null value.
+ *
+ * @return the resource id
+ */
+ String getResourceId();
+
+ /**
+ * Returns the cacheability.
+ *
+ * @return the cacheability
+ */
+ Cacheability getCacheability();
+
+ /**
+ * Returns the resource state of the request.
+ *
+ * @return the resource state
+ */
+ StateString getResourceState();
+
+ /**
+ * Returns the form parameters of the request or null if no form could be decoded by
the caller.
+ *
+ * @return the request form
+ */
+ ParameterMap getForm();
+
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/support/spi/PortletInvocationContextSupport.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -27,8 +27,8 @@
import org.jboss.portal.common.invocation.AbstractInvocationContext;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
/**
@@ -68,7 +68,7 @@
throw new UnsupportedOperationException();
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
throw new UnsupportedOperationException();
}
Modified:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java
===================================================================
---
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/jsr286/tck/event/EventPayloadTypeConformanceTestCase.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -72,9 +72,9 @@
private static final Date date = new Date();
private static final QName name = new QName("foons",
"foolocalname");
- private static final List<Serializable> payloads = new
ArrayList<Serializable>();
+ /** . */
+ private final List<Serializable> payloads = new
ArrayList<Serializable>();
- static
{
payloads.add(true);
payloads.add(1); // int
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletController.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -25,6 +25,8 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.spi.ResourceInvocationContext;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.EventInfo;
import org.jboss.portal.portlet.info.ParameterInfo;
@@ -43,6 +45,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.web.IllegalRequestException;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.MarkupInfo;
@@ -107,32 +110,33 @@
return publicNavigationalState;
}
- private PortletInvocationResponse handle(PortletControllerContext context, Action
action) throws PortletInvokerException, IOException
+ private PortletInvocationResponse handle(PortletControllerContext context,
ContainerRequest containerRequest) throws PortletInvokerException, IOException
{
- if (action instanceof PortletRender)
+ Portlet portlet = context.getPortlet(containerRequest.portletId);
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState portalNS = context.getNavigationalState();
+ WindowNavigationalState windowNS =
portalNS.getWindowNavigationalState(containerRequest.portletId);
+ PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS, portlet,
req, resp);
+
+ //
+ if (containerRequest instanceof PortletRenderRequest)
{
- PortletRender portletRender = (PortletRender)action;
+ PortletRenderRequest portletRenderRequest =
(PortletRenderRequest)containerRequest;
//
UpdateNavigationalStateResponse updateNavigationalState = new
UpdateNavigationalStateResponse();
- updateNavigationalState.setMode(action.mode);
- updateNavigationalState.setWindowState(action.windowState);
-
updateNavigationalState.setNavigationalState(portletRender.navigationalParameters);
+ updateNavigationalState.setMode(portletRenderRequest.mode);
+ updateNavigationalState.setWindowState(portletRenderRequest.windowState);
+
updateNavigationalState.setNavigationalState(portletRenderRequest.navigationalState);
return updateNavigationalState;
}
- else
+ else if (containerRequest instanceof PortletActionRequest)
{
- PortletAction portletAction = (PortletAction)action;
+ PortletActionRequest portletActionRequest =
(PortletActionRequest)containerRequest;
- Portlet portlet = context.getPortlet(action.portletId);
- HttpServletRequest req = context.getClientRequest();
- HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState navState = context.getNavigationalState();
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
- WindowNavigationalState windowNS =
navState.getWindowNavigationalState(action.portletId);
-
//
- Mode mode = action.mode;
+ Mode mode = portletActionRequest.mode;
if (mode == null && windowNS != null && windowNS.getMode() !=
null)
{
mode = windowNS.getMode();
@@ -143,7 +147,7 @@
}
//
- WindowState windowState = action.windowState;
+ WindowState windowState = portletActionRequest.windowState;
if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
{
windowState = windowNS.getWindowState();
@@ -162,11 +166,11 @@
renderer,
mode,
windowState,
- portletAction.navigationalParameters,
+ portletActionRequest.navigationalState,
publicNS,
MARKUP_INFO,
- portletAction.interactionParameters,
- portletAction.bodyParameters != null ?
ParameterMap.clone(portletAction.bodyParameters) : null);
+ portletActionRequest.interactionState,
+ portletActionRequest.bodyParameters != null ?
ParameterMap.clone(portletActionRequest.bodyParameters) : null);
ActionInvocation actionInvocation = new ActionInvocation(actionContext);
//
@@ -189,6 +193,70 @@
return null;
}
}
+ else
+ {
+ PortletResourceRequest portletResourceRequest =
(PortletResourceRequest)containerRequest;
+
+ //
+ Mode mode = Mode.VIEW;
+ if (mode == null && windowNS != null && windowNS.getMode() !=
null)
+ {
+ mode = windowNS.getMode();
+ }
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ //
+ WindowState windowState = WindowState.NORMAL;
+ if (windowState == null && windowNS != null &&
windowNS.getWindowState() != null)
+ {
+ windowState = windowNS.getWindowState();
+ }
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+
+ //
+ ParameterMap publicNS = getPublicNavigationalState(context, portlet);
+
+ //
+ TestInstanceContext instanceContext = new TestInstanceContext(req,
portlet.getContext(), true);
+ ResourceInvocationContext resourceInvocationContext = new ResourceTestContext(
+ portletResourceRequest.resourceId,
+ portletResourceRequest.resourceCacheability,
+ renderer,
+ mode,
+ windowState,
+ portletResourceRequest.navigationalState,
+ publicNS,
+ portletResourceRequest.resourceState,
+ portletResourceRequest.bodyParameters != null ?
ParameterMap.clone(portletResourceRequest.bodyParameters) : null,
+ MARKUP_INFO);
+ ResourceInvocation resourceInvocation = new
ResourceInvocation(resourceInvocationContext);
+
+ //
+ resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
+ resourceInvocation.setInstanceContext(instanceContext);
+ resourceInvocation.setUserContext(new AbstractUserContext(req));
+ resourceInvocation.setWindowContext(new
AbstractWindowContext(portlet.getContext().getId()));
+ resourceInvocation.setPortalContext(new AbstractPortalContext());
+ 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(
@@ -199,8 +267,8 @@
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
PortalNavigationalState navState = context.getNavigationalState();
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
WindowNavigationalState windowNS =
navState.getWindowNavigationalState(portlet.getContext().getId());
+ PortletURLRenderer renderer = new PortletURLRenderer(navState, windowNS, portlet,
req, resp);
//
if (windowNS == null)
@@ -240,20 +308,35 @@
}
catch (PortletInvokerException e)
{
+ log.error("Error during event invocation", e);
+
+ //
return null;
}
}
- public void process(PortletControllerContext context, Action action) throws
PortletInvokerException, IOException
+ public void process(PortletControllerContext context, ControllerRequest
controllerRequest) throws PortletInvokerException, IOException
{
+ if (controllerRequest == null)
+ {
+ render(context);
+ }
+ else if (controllerRequest instanceof ContainerRequest)
+ {
+ process(context, (ContainerRequest)controllerRequest);
+ }
+ }
+
+ public void process(PortletControllerContext context, ContainerRequest
containerRequest) throws PortletInvokerException, IOException
+ {
HttpServletRequest req = context.getClientRequest();
HttpServletResponse resp = context.getClientResponse();
- PortalNavigationalState navState = context.getNavigationalState();
+ PortalNavigationalState portalNS = context.getNavigationalState();
//
- if (action != null)
+ if (containerRequest instanceof PortletRequest)
{
- PortletInvocationResponse response = handle(context, action);
+ PortletInvocationResponse response = handle(context, containerRequest);
//
if (response instanceof ErrorResponse)
@@ -280,7 +363,7 @@
// Update portlet NS
if (response instanceof UpdateNavigationalStateResponse)
{
- updateNavigationalState(context, action.portletId,
(UpdateNavigationalStateResponse)response);
+ updateNavigationalState(context, containerRequest.portletId,
(UpdateNavigationalStateResponse)response);
}
// Create event list and feed it with the events that may have been produced
@@ -359,10 +442,6 @@
System.out.println("Not yet handled " + response);
}
-
-
-
-
/*
if (response instanceof RenderResponse && redirectAfterAction)
{
@@ -386,8 +465,22 @@
response = new HTTPRedirectionResponse(location);
}
*/
+
+ //
+ render(context);
}
+ else if (containerRequest instanceof PortletResourceRequest)
+ {
+ PortletInvocationResponse response = handle(context, containerRequest);
+ }
+ }
+ private void render(PortletControllerContext context) throws IOException
+ {
+ HttpServletRequest req = context.getClientRequest();
+ HttpServletResponse resp = context.getClientResponse();
+ PortalNavigationalState portalNS = context.getNavigationalState();
+
//
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
@@ -399,15 +492,19 @@
for (Portlet portlet : context.getPortlets())
{
writer.print("<div><div>" + portlet.getContext() +
"</div>");
- PortletURLRenderer renderer = new PortletURLRenderer(navState, portlet, req,
resp);
//
+ WindowNavigationalState windowNS =
portalNS.getWindowNavigationalState(portlet.getContext().getId());
+
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(portalNS, windowNS,
portlet, req, resp);
+
+ //
Mode mode = Mode.VIEW;
WindowState windowState = WindowState.NORMAL;
StateString portletNS = null;
//
- WindowNavigationalState windowNS =
navState.getWindowNavigationalState(portlet.getContext().getId());
if (windowNS != null)
{
if (windowNS.getMode() != null)
@@ -462,6 +559,7 @@
}
writer.print("</body></html>");
+
}
private void updateNavigationalState(
@@ -529,75 +627,120 @@
}
}
- static class Action
+ static class ControllerRequest
{
+ }
+ static class ContainerRequest extends ControllerRequest
+ {
/** . */
final String portletId;
+ ContainerRequest(String portletId)
+ {
+ this.portletId = portletId;
+ }
+ }
+
+ static class PortletRequest extends ContainerRequest
+ {
+
/** . */
final Mode mode;
/** . */
final WindowState windowState;
- public Action(
- String portletId,
- Mode mode,
- WindowState windowState)
+ PortletRequest(String portletId, Mode mode, WindowState windowState)
{
- this.portletId = portletId;
+ super(portletId);
this.mode = mode;
this.windowState = windowState;
}
}
- static class PortletAction extends Action
+
+ static class PortletResourceRequest extends ContainerRequest
{
/** . */
- final StateString navigationalParameters;
+ final String resourceId;
/** . */
- final StateString interactionParameters;
+ final Cacheability resourceCacheability;
/** . */
- final Map<String, String[]> bodyParameters;
+ final StateString navigationalState;
- public PortletAction(
+ /** . */
+ final StateString resourceState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ PortletResourceRequest(
String portletId,
- StateString navigationalParameters,
- StateString interactionParameters,
- Map<String, String[]> bodyParameters,
+ String resourceId,
+ Cacheability resourceCacheability,
+ StateString resourceState,
+ ParameterMap bodyParameters,
+ StateString navigationalState
+ )
+ {
+ super(portletId);
+ this.resourceId = resourceId;
+ this.resourceCacheability = resourceCacheability;
+ this.navigationalState = navigationalState;
+ this.resourceState = resourceState;
+ this.bodyParameters = bodyParameters;
+ }
+ }
+
+ static class PortletActionRequest extends PortletRequest
+ {
+
+ /** . */
+ final StateString navigationalState;
+
+ /** . */
+ final StateString interactionState;
+
+ /** . */
+ final ParameterMap bodyParameters;
+
+ public PortletActionRequest(
+ String portletId,
+ StateString interactionState,
+ ParameterMap bodyParameters,
+ StateString navigationalState,
Mode mode,
WindowState windowState)
{
super(portletId, mode, windowState);
//
- this.navigationalParameters = navigationalParameters;
- this.interactionParameters = interactionParameters;
+ this.navigationalState = navigationalState;
+ this.interactionState = interactionState;
this.bodyParameters = bodyParameters;
}
}
- static class PortletRender extends Action
+ static class PortletRenderRequest extends PortletRequest
{
/** . */
- final StateString navigationalParameters;
+ final StateString navigationalState;
-
- public PortletRender(
+ public PortletRenderRequest(
String portletId,
- StateString navigationalParameters,
+ StateString navigationalState,
Mode mode,
WindowState windowState)
{
super(portletId, mode, windowState);
//
- this.navigationalParameters = navigationalParameters;
+ this.navigationalState = navigationalState;
}
}
}
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-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletControllerContextImpl.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -32,6 +32,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Cacheability;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.web.Body;
@@ -70,7 +71,7 @@
private final PortalNavigationalState navState;
/** . */
- private final PortletController.Action action;
+ private final PortletController.ControllerRequest request;
/** . */
private final PortletInvoker invoker;
@@ -81,16 +82,10 @@
ServletContext servletContext)
throws IllegalRequestException, IOException, ClassNotFoundException
{
-// if (navStateScope < NAV_SCOPE || navStateScope > SESSION_SCOPE)
-// {
-// throw new IllegalArgumentException();
-// }
-
- //
PortletInvoker invoker =
(PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
PortalNavigationalState navState;
- PortletController.Action action;
+ PortletController.ControllerRequest request;
// decode request
String pathInfo = req.getPathInfo();
@@ -100,17 +95,6 @@
WebRequest ri = new WebRequest(req);
-// if (navStateScope == NAV_SCOPE)
-// {
-// String ns = metaParameters.getValue("ns");
-// byte[] bytes = Tools.fromHexString(ns);
-// navState = PortalNavigationalState.create(bytes);
-// }
-// else
-// {
-// navState =
(PortalNavigationalState)req.getSession().getAttribute("nav_state");
-// }
-
// Unmarshall portal navigational state
String context = req.getParameter("context");
byte[] bytes = Tools.fromHexString(context);
@@ -119,30 +103,13 @@
//
String type = req.getParameter("type");
- //
- Mode mode = null;
- if (req.getParameter("mode") != null)
- {
- mode = Mode.create(req.getParameter("mode"));
- }
//
- WindowState windowState = null;
- if (req.getParameter("windowstate") != null)
+ if ("resource".equals(type))
{
- windowState = WindowState.create(req.getParameter("windowstate"));
- }
+ StateString resourceState =
ParametersStateString.create(req.getParameter("resourcestate"));
+ String resourceId = req.getParameter("id");
-
-
- if ("action".equals(type))
- {
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
//
String navigationalStateString =
req.getParameter("navigationalstate");
StateString navigationalState = null;
@@ -152,42 +119,90 @@
}
//
- StateString interactionState =
ParametersStateString.create(req.getParameter("interactionstate"));
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
//
- action = new PortletController.PortletAction(targetId, navigationalState,
interactionState, formParameters, mode, windowState);
+ Cacheability resourceCacheability =
Cacheability.valueOf(req.getParameter("cacheability"));
+
+ //
+ request = new PortletController.PortletResourceRequest(
+ targetId,
+ resourceId,
+ resourceCacheability,
+ resourceState,
+ formParameters,
+ navigationalState);
}
else
{
- StateString navigationalState =
ParametersStateString.create(req.getParameter("navigationalstate"));
+ //
+ Mode mode = null;
+ if (req.getParameter("mode") != null)
+ {
+ mode = Mode.create(req.getParameter("mode"));
+ }
//
- action = new PortletController.PortletRender(targetId, navigationalState,
mode, windowState);
+ WindowState windowState = null;
+ if (req.getParameter("windowstate") != null)
+ {
+ windowState =
WindowState.create(req.getParameter("windowstate"));
+ }
+
+ //
+ if ("action".equals(type))
+ {
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ String navigationalStateString =
req.getParameter("navigationalstate");
+ StateString navigationalState = null;
+ if (navigationalStateString != null)
+ {
+ navigationalState =
ParametersStateString.create(navigationalStateString);
+ }
+
+ //
+ StateString interactionState =
ParametersStateString.create(req.getParameter("interactionstate"));
+
+ //
+ request = new PortletController.PortletActionRequest(targetId,
interactionState, formParameters, navigationalState, mode, windowState);
+ }
+ else
+ {
+ StateString navigationalState =
ParametersStateString.create(req.getParameter("navigationalstate"));
+
+ //
+ request = new PortletController.PortletRenderRequest(targetId,
navigationalState, mode, windowState);
+ }
}
}
else
{
navState = new PortalNavigationalState();
- action = null;
-
- //
-// if (navStateScope == SESSION_SCOPE)
-// {
-// req.getSession().setAttribute("nav_state", navState);
-// }
+ request = null;
}
+ //
this.navState = navState;
- this.action = action;
+ this.request = request;
this.req = req;
this.resp = resp;
this.servletContext = servletContext;
this.invoker = invoker;
}
- public PortletController.Action getRequest()
+ public PortletController.ControllerRequest getRequest()
{
- return action;
+ return request;
}
public PortalNavigationalState getNavigationalState()
@@ -212,8 +227,7 @@
public Portlet getPortlet(String portletId) throws PortletInvokerException
{
- PortletContext target = PortletContext.createPortletContext(action.portletId);
- return invoker.getPortlet(target);
+ return invoker.getPortlet(PortletContext.createPortletContext(portletId));
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortletURLRenderer.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ResourceURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
@@ -48,27 +50,32 @@
final Portlet portlet;
/** . */
+ final WindowNavigationalState windowNS;
+
+ /** . */
final HttpServletRequest clientReq;
/** . */
final HttpServletResponse clientResp;
/** . */
- final PortalNavigationalState navState;
+ final PortalNavigationalState portalNS;
public PortletURLRenderer(
- PortalNavigationalState navState,
+ PortalNavigationalState portalNS,
+ WindowNavigationalState windowNS,
Portlet portlet,
HttpServletRequest clientReq,
HttpServletResponse clientResp)
{
- this.navState = navState;
+ this.portalNS = portalNS;
+ this.windowNS = windowNS;
this.portlet = portlet;
this.clientReq = clientReq;
this.clientResp = clientResp;
}
- String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated,
boolean relative)
+ String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
CharBuffer buffer = new CharBuffer();
buffer.append(clientReq.getScheme());
@@ -84,12 +91,29 @@
Map<String, String> parameters = new HashMap<String, String>();
//
- parameters.put("type", portletURL instanceof RenderURL ?
"render" : "action");
+ String type;
+ if (containerURL instanceof ActionURL)
+ {
+ type = "action";
+ }
+ else if (containerURL instanceof RenderURL)
+ {
+ type = "render";
+ }
+ else if (containerURL instanceof ResourceURL)
+ {
+ type = "resource";
+ }
+ else
+ {
+ throw new Error();
+ }
+ parameters.put("type", type);
//
try
{
- byte[] bytes = PortalNavigationalState.serialize(navState);
+ byte[] bytes = PortalNavigationalState.serialize(portalNS);
String ns = Tools.toHexString(bytes);
parameters.put("context", ns);
}
@@ -99,38 +123,75 @@
}
//
- if (portletURL.getMode() != null)
+ if (containerURL instanceof PortletURL)
{
- parameters.put("mode", portletURL.getMode().toString());
- }
+ PortletURL portletURL = (PortletURL)containerURL;
- //
- if (portletURL.getWindowState() != null)
- {
- parameters.put("windowstate",
portletURL.getWindowState().toString());
- }
+ if (portletURL.getMode() != null)
+ {
+ parameters.put("mode", portletURL.getMode().toString());
+ }
- //
- if (portletURL instanceof RenderURL)
- {
- StateString navigationalState = ((RenderURL)portletURL).getNavigationalState();
+ //
+ if (portletURL.getWindowState() != null)
+ {
+ parameters.put("windowstate",
portletURL.getWindowState().toString());
+ }
//
- parameters.put("navigationalstate",
navigationalState.getStringValue());
+ if (containerURL instanceof ActionURL)
+ {
+ ActionURL actionURL = (ActionURL)containerURL;
+
+ //
+ StateString navigationalState = actionURL.getNavigationalState();
+ if (navigationalState != null)
+ {
+ parameters.put("navigationalstate",
navigationalState.getStringValue());
+ }
+
+ //
+ StateString interactionState = actionURL.getInteractionState();
+ parameters.put("interactionstate",
interactionState.getStringValue());
+ }
+ else
+ {
+ RenderURL renderURL = (RenderURL)containerURL;
+
+ //
+ StateString navigationalState = renderURL.getNavigationalState();
+ parameters.put("navigationalstate",
navigationalState.getStringValue());
+ }
}
else
{
- StateString navigationalState = ((ActionURL)portletURL).getNavigationalState();
- StateString interactionState = ((ActionURL)portletURL).getInteractionState();
+ ResourceURL resourceURL = (ResourceURL)containerURL;
//
- if (navigationalState != null)
+ StateString resourceState = resourceURL.getResourceState();
+ parameters.put("resourcestate", resourceState.getStringValue());
+
+ //
+ String resourceId = resourceURL.getId();
+ if (resourceId != null)
{
- parameters.put("navigationalstate",
navigationalState.getStringValue());
+ parameters.put("id", resourceId);
}
//
- parameters.put("interactionstate",
interactionState.getStringValue());
+ parameters.put("cacheability", resourceURL.getCacheability().name());
+ switch (resourceURL.getCacheability())
+ {
+ case FULL:
+ // todo
+ break;
+ case PORTLET:
+ // todo
+ break;
+ case PAGE:
+ // todo
+ break;
+ }
}
//
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/ResourceTestContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.Cacheability;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.spi.AbstractResourceContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResourceTestContext extends AbstractResourceContext
+{
+
+ /** . */
+ private final PortletURLRenderer urlRenderer;
+
+ public ResourceTestContext(
+ String resourceId,
+ Cacheability resourceCacheability,
+ PortletURLRenderer urlRenderer,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
+ ParameterMap publicNavigationalState,
+ StateString resourceState,
+ ParameterMap form,
+ MarkupInfo markupInfo)
+ {
+ super(
+ resourceId,
+ resourceCacheability,
+ mode,
+ windowState,
+ navigationalState,
+ publicNavigationalState,
+ resourceState,
+ form,
+ markupInfo);
+
+ //
+ this.urlRenderer = urlRenderer;
+
+ //
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(urlRenderer.clientReq));
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return urlRenderer.clientReq;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return urlRenderer.clientResp;
+ }
+
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated,
relative);
+ }
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestActionContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
import org.jboss.portal.Mode;
@@ -79,8 +79,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated,
relative);
}
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestEventContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,9 +23,8 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
import org.jboss.portal.portlet.impl.spi.AbstractEventContext;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -82,8 +81,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated,
relative);
}
}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-21
15:44:23 UTC (rev 9547)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/TestRenderContext.java 2008-01-21
21:32:53 UTC (rev 9548)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.test;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
import org.jboss.portal.Mode;
@@ -77,8 +77,8 @@
return urlRenderer.clientResp;
}
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated,
relative);
}
}