Author: julien(a)jboss.com
Date: 2008-04-11 18:10:42 -0400 (Fri, 11 Apr 2008)
New Revision: 10544
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/InvokePortletInstanceCommandFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
Log:
start to add support for resource serving
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.ResourceURL;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -47,4 +48,12 @@
* @return a controller command
*/
ControllerCommand createInvokeRenderCommand(RenderURL portletURL);
+
+ /**
+ * Creates a command that will trigger the resource url.
+ *
+ * @param resourceURL the resource url
+ * @return a controller command
+ */
+ ControllerCommand createInvokeResourceCommand(ResourceURL resourceURL);
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -36,10 +36,12 @@
import org.jboss.portal.core.model.portal.Window;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
+import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowResourceCommand;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.RenderURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ResourceURL;
import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -224,16 +226,27 @@
Boolean wantAuthenticated,
boolean relative)
{
- ControllerCommand cmd;
+ ControllerCommand cmd = null;
+
+ //
if (containerURL instanceof ActionURL)
{
cmd = factory.createInvokeActionCommand((ActionURL)containerURL);
}
- else
+ else if (containerURL instanceof RenderURL)
{
cmd = factory.createInvokeRenderCommand((RenderURL)containerURL);
}
+ else if (containerURL instanceof ResourceURL)
+ {
+ cmd = factory.createInvokeResourceCommand((ResourceURL)containerURL);
+ }
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No container url such as " +
containerURL + " can be rendered by the core");
+ }
+
//
boolean secure =
controllerContext.getServerInvocation().getServerContext().getURLContext().isSecure();
if (wantSecure != null)
@@ -318,5 +331,18 @@
{
return new InvokePortletWindowRenderCommand(window.getId(), renderURL.getMode(),
renderURL.getWindowState(), renderURL.getNavigationalState());
}
+
+ public ControllerCommand createInvokeResourceCommand(ResourceURL resourceURL)
+ {
+ return new InvokePortletWindowResourceCommand(
+ window.getId(),
+ resourceURL.getMode(),
+ resourceURL.getWindowState(),
+ resourceURL.getCacheability(),
+ resourceURL.getResourceId(),
+ resourceURL.getResourceState(),
+ null
+ );
+ }
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/InvokePortletInstanceCommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/InvokePortletInstanceCommandFactory.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/InvokePortletInstanceCommandFactory.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -28,6 +28,7 @@
import
org.jboss.portal.core.model.instance.command.action.InvokePortletInstanceRenderCommand;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.ResourceURL;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -59,4 +60,12 @@
instanceId,
portletURL.getNavigationalState());
}
+
+ /**
+ * We don't implement (yet?) for instances as it is rather internal and not needed
yet.
+ */
+ public ControllerCommand createInvokeResourceCommand(ResourceURL resourceURL)
+ {
+ return null;
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -35,7 +35,7 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
-import org.jboss.portal.portlet.controller.request.PortletRequest;
+import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
@@ -138,7 +138,7 @@
return context.getController().getCustomizationManager().getInstance(window,
user);
}
- protected PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
+ protected ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
return new PortletActionRequest(
window.getName(),
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -29,7 +29,7 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
-import org.jboss.portal.portlet.controller.request.PortletRequest;
+import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
@@ -44,6 +44,7 @@
public class InvokePortletWindowRenderCommand extends InvokeWindowCommand
{
+ /** . */
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
@@ -84,7 +85,7 @@
return info;
}
- protected PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
+ protected ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
Mode newMode = null;
WindowState newWindowState = null;
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.model.portal.command.action;
+
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.controller.request.PortletResourceRequest;
+import org.jboss.portal.portlet.controller.request.ContainerRequest;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.StateString;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class InvokePortletWindowResourceCommand extends InvokeWindowCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ActionCommandInfo(true);
+
+ /** . */
+ private final CacheLevel cacheLevel;
+
+ /** . */
+ private final String resourceId;
+
+ /** . */
+ private final StateString resourceState;
+
+ /** . */
+ private final ParameterMap resourceForm;
+
+ public InvokePortletWindowResourceCommand(
+ PortalObjectId windowId,
+ Mode mode,
+ WindowState windowState,
+ CacheLevel cacheLevel,
+ String resourceId,
+ StateString resourceState,
+ ParameterMap resourceForm) throws IllegalArgumentException
+ {
+ super(windowId, mode, windowState);
+
+ //
+ this.cacheLevel = cacheLevel;
+ this.resourceId = resourceId;
+ this.resourceState = resourceState;
+ this.resourceForm = resourceForm;
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ protected ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
+ {
+ PortletResourceRequest.Scope scope;
+ switch (cacheLevel)
+ {
+ case FULL:
+ scope = new PortletResourceRequest.FullScope();
+ break;
+ case PORTLET:
+ scope = new PortletResourceRequest.PortletScope(windowNS);
+ break;
+ case PAGE:
+ scope = new PortletResourceRequest.PageScope(windowNS, pageNS);
+ break;
+ default:
+ throw new AssertionError();
+ }
+
+ return new PortletResourceRequest(
+ window.getName(),
+ resourceId,
+ resourceState,
+ resourceForm,
+ scope);
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-11
21:51:59 UTC (rev 10543)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-11
22:10:42 UTC (rev 10544)
@@ -27,6 +27,7 @@
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.controller.request.PortletRequest;
+import org.jboss.portal.portlet.controller.request.ContainerRequest;
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.PortletResponse;
@@ -72,7 +73,7 @@
return windowState;
}
- protected abstract PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS);
+ protected abstract ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS);
public ControllerResponse execute() throws ControllerException
{
@@ -91,13 +92,13 @@
WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(window.getName());
//
- PortletRequest portletRequest = createPortletRequest(pageNS, windowNS);
+ ContainerRequest containerRequest = createPortletRequest(pageNS, windowNS);
//
PortletController controller = new PortletController();
//
- org.jboss.portal.portlet.controller.response.ControllerResponse cr =
controller.process(cpcc, portletRequest);
+ org.jboss.portal.portlet.controller.response.ControllerResponse cr =
controller.process(cpcc, containerRequest);
//
if (cr instanceof PageUpdateResponse)