Author: julien(a)jboss.com
Date: 2008-04-12 10:59:26 -0400 (Sat, 12 Apr 2008)
New Revision: 10551
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.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/portal/PortalObjectCommandFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.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/InvokePortletWindowResourceCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java
Log:
support for resource serving
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/classic/OtherResponseHandler.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -126,7 +126,15 @@
else if (controllerResponse instanceof StreamContentResponse)
{
StreamContentResponse scr = (StreamContentResponse)controllerResponse;
- return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(),
scr.getInputStream());
+
+ if (scr.getInputStream() != null)
+ {
+ return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(),
scr.getInputStream());
+ }
+ else
+ {
+ return HTTPResponse.sendBinary(scr.getContentType(), scr.getLastModified(),
scr.getReader());
+ }
}
else if (controllerResponse instanceof SecurityErrorResponse)
{
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/response/StreamContentResponse.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -25,6 +25,7 @@
import org.jboss.portal.core.controller.ControllerResponse;
import java.io.InputStream;
+import java.io.Reader;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -34,17 +35,22 @@
{
/** . */
- private String contentType;
+ private final String contentType;
/**
* The time the content was last modified, measured in milliseconds since
- * the epoch (00:00:00 GMT, January 1, 1970).
+ * the epoch (00:00:00 GMT, January 1, 1970). If the value is not greater than zero
then
+ * the last modified field does not represent a valid last modified date and it is
left
+ * up to the streamer to interpret it.
*/
- private long lastModified;
+ private final long lastModified;
/** . */
- private InputStream inputStream;
+ private final InputStream inputStream;
+ /** . */
+ private final Reader reader;
+
public StreamContentResponse(String contentType, long lastModified, InputStream
inputStream)
{
if (contentType == null)
@@ -55,11 +61,32 @@
{
throw new IllegalArgumentException();
}
+
+ //
this.contentType = contentType;
this.lastModified = lastModified;
this.inputStream = inputStream;
+ this.reader = null;
}
+ public StreamContentResponse(String contentType, long lastModified, Reader reader)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (reader == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.contentType = contentType;
+ this.lastModified = lastModified;
+ this.inputStream = null;
+ this.reader = reader;
+ }
+
public String getContentType()
{
return contentType;
@@ -74,4 +101,9 @@
{
return inputStream;
}
+
+ public Reader getReader()
+ {
+ return reader;
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/handler/HTTPResponse.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -30,6 +30,8 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
/**
* Response that sends a response to the http layer.
@@ -61,19 +63,22 @@
public void sendResponse(ServerInvocationContext ctx) throws IOException
{
HttpServletResponse resp = ctx.getClientResponse();
+
+ //
resp.setContentType(contentType);
- resp.addDateHeader("Last-Modified", lastModified);
+
+ //
+ if (lastModified > 0)
+ {
+ resp.addDateHeader("Last-Modified", lastModified);
+ }
+
+ //
ServletOutputStream sout = null;
try
{
sout = resp.getOutputStream();
- byte[] buf = new byte[2048];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- sout.write(buf, 0, len);
- }
- sout.flush();
+ IOTools.copy(in, sout);
}
finally
{
@@ -84,6 +89,39 @@
};
}
+ public static HTTPResponse sendBinary(final String contentType, final long
lastModified, final Reader reader)
+ {
+ return new HTTPResponse()
+ {
+ public void sendResponse(ServerInvocationContext ctx) throws IOException
+ {
+ HttpServletResponse resp = ctx.getClientResponse();
+
+ //
+ resp.setContentType(contentType);
+
+ //
+ if (lastModified > 0)
+ {
+ resp.addDateHeader("Last-Modified", lastModified);
+ }
+
+ //
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ IOTools.copy(reader, writer);
+ }
+ finally
+ {
+ IOTools.safeClose(reader);
+ IOTools.safeClose(writer);
+ }
+ }
+ };
+ }
+
public static HTTPResponse sendForbidden()
{
return sendStatus(HttpServletResponse.SC_FORBIDDEN);
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -166,7 +166,7 @@
public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
{
- PortletInvocationFactory.contextualizeAction(actionInvocation);
+ PortletInvocationFactory.contextualize(actionInvocation);
//
Window window = PortletInvocationFactory.getTargetWindow(actionInvocation);
@@ -185,7 +185,16 @@
public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws
PortletInvokerException
{
- throw new NotYetImplemented();
+ PortletInvocationFactory.contextualize(resourceInvocation);
+
+ //
+ Window window = PortletInvocationFactory.getTargetWindow(resourceInvocation);
+
+ //
+ Instance instance = instances.get(window.getName());
+
+ //
+ return instance.invoke(resourceInvocation);
}
public EventControllerContext getEventControllerContext()
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerResponseFactory.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -25,12 +25,14 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.FixMe;
+import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.response.ErrorResponse;
import org.jboss.portal.core.controller.command.response.RedirectionResponse;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
import org.jboss.portal.core.controller.command.response.SignOutResponse;
import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
+import org.jboss.portal.core.controller.command.response.StreamContentResponse;
import
org.jboss.portal.core.model.instance.command.response.PortletInstanceActionResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.PortletWindowActionResponse;
@@ -38,7 +40,11 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -123,6 +129,30 @@
org.jboss.portal.portlet.invocation.response.SecurityErrorResponse ser =
(org.jboss.portal.portlet.invocation.response.SecurityErrorResponse)response;
return new SecurityErrorResponse(ser.getThrowable(),
SecurityErrorResponse.NOT_AUTHORIZED, false);
}
+ else if (response instanceof ContentResponse)
+ {
+ ContentResponse contentResponse = (ContentResponse)response;
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_EMPTY)
+ {
+ throw new NotYetImplemented("todo");
+ }
+ else
+ {
+ String contentType = contentResponse.getContentType();
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_BYTES)
+ {
+ return new StreamContentResponse(contentType, -1, new
ByteArrayInputStream(contentResponse.getBytes()));
+ }
+ else
+ {
+ return new StreamContentResponse(contentType, -1, new
StringReader(contentResponse.getChars()));
+ }
+ }
+ }
else
{
throw new FixMe("Undefined response mapping for " + response);
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-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -46,6 +46,7 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.request.URLContext;
@@ -57,8 +58,11 @@
*/
public class PortletInvocationFactory
{
+
+ /** Remove me / flawed. */
public static ThreadLocal<ControllerContext> controllerContextTL = new
ThreadLocal<ControllerContext>();
+ /** Remove me / flawed. */
public static ThreadLocal<UserContext> userContextTL = new
ThreadLocal<UserContext>();
public static InvokePortletCommandFactory
createInvokePortletCommandFactory(ControllerContext controllerContext, Window window)
@@ -78,19 +82,6 @@
return createInvocationContext(controllerContext, ipcf);
}
- public static RenderInvocation createRender(
- ControllerContext controllerContext,
- Mode mode,
- WindowState windowState,
- StateString navigationalState,
- Window window,
- Portal portal)
- {
- PortletContextFactory cf = new PortletContextFactory(controllerContext, portal,
window);
- InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window);
- return createRender(controllerContext, mode, windowState, navigationalState, cf,
cpc);
- }
-
public static ActionInvocation createAction(
ControllerContext controllerContext,
Mode mode,
@@ -117,7 +108,7 @@
InvokePortletCommandFactory cpc)
{
PortletInvocationContext portletInvocationContext =
createInvocationContext(controllerContext, cpc);
-
+
//
ActionInvocation action = new ActionInvocation(portletInvocationContext);
@@ -129,7 +120,7 @@
action.setInteractionState(interactionState);
//
- contextualizeAction(controllerContext, cf, action);
+ contextualize(controllerContext, cf, action);
//
return action;
@@ -140,6 +131,19 @@
Mode mode,
WindowState windowState,
StateString navigationalState,
+ Window window,
+ Portal portal)
+ {
+ PortletContextFactory cf = new PortletContextFactory(controllerContext, portal,
window);
+ InvokePortletCommandFactory cpc =
createInvokePortletCommandFactory(controllerContext, window);
+ return createRender(controllerContext, mode, windowState, navigationalState, cf,
cpc);
+ }
+
+ public static RenderInvocation createRender(
+ ControllerContext controllerContext,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState,
PortletContextFactory cf,
InvokePortletCommandFactory cpc)
{
@@ -154,15 +158,18 @@
render.setNavigationalState(navigationalState);
//
- return contextualizeRender(controllerContext, cf, render);
+ contextualize(controllerContext, cf, render);
+
+ //
+ return render;
}
- public static RenderInvocation contextualizeRender(
+ public static void contextualize(
ControllerContext controllerContext,
PortletContextFactory cf,
- RenderInvocation render)
+ PortletInvocation invocation)
{
- render.setAttribute(PortletInvocation.INVOCATION_SCOPE,
"controller_context", controllerContext);
+ invocation.setAttribute(PortletInvocation.INVOCATION_SCOPE,
"controller_context", controllerContext);
//
UserContext userContext = cf.createUserContext();
@@ -172,52 +179,44 @@
userContextTL.set(userContext);
// Contextualize
- render.setSecurityContext(cf.createSecurityContext());
- render.setPortalContext(cf.createPortalContext());
- render.setWindowContext(cf.createWindowContext());
- render.setUserContext(cf.createUserContext());
- render.setServerContext(cf.createServerContext());
- render.setClientContext(cf.createClientContext());
+ invocation.setSecurityContext(cf.createSecurityContext());
+ invocation.setPortalContext(cf.createPortalContext());
+ invocation.setWindowContext(cf.createWindowContext());
+ invocation.setUserContext(cf.createUserContext());
+ invocation.setServerContext(cf.createServerContext());
+ invocation.setClientContext(cf.createClientContext());
//
- return render;
+ if (invocation instanceof ActionInvocation)
+ {
+ ActionInvocation action = (ActionInvocation)invocation;
+
+ //
+ action.setRequestContext(cf.createRequestContext());
+ }
+ else if (invocation instanceof ResourceInvocation)
+ {
+ ResourceInvocation resource = (ResourceInvocation)invocation;
+
+ //
+ resource.setRequestContext(cf.createRequestContext());
+ }
}
- public static Window getTargetWindow(ActionInvocation action)
+ public static Window getTargetWindow(PortletInvocation action)
{
ControllerPortletInvocationContext cpic =
(ControllerPortletInvocationContext)action.getContext();
InternalInvokePortletCommandFactory iipcf =
(InternalInvokePortletCommandFactory)cpic.cmdFactory;
return iipcf.window;
}
- public static void contextualizeAction(ActionInvocation action)
+ public static void contextualize(PortletInvocation action)
{
ControllerPortletInvocationContext cpic =
(ControllerPortletInvocationContext)action.getContext();
Window window = getTargetWindow(action);
- contextualizeAction(cpic.controllerContext, new
PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window),
action);
+ contextualize(cpic.controllerContext, new
PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window),
action);
}
- public static void contextualizeAction(
- ControllerContext controllerContext,
- PortletContextFactory cf,
- ActionInvocation action)
- {
- UserContext userContext = cf.createUserContext();
-
- //
- controllerContextTL.set(controllerContext);
- userContextTL.set(userContext);
-
- // Contextualize
- action.setSecurityContext(cf.createSecurityContext());
- action.setRequestContext(cf.createRequestContext());
- action.setPortalContext(cf.createPortalContext());
- action.setWindowContext(cf.createWindowContext());
- action.setUserContext(userContext);
- action.setServerContext(cf.createServerContext());
- action.setClientContext(cf.createClientContext());
- }
-
public static String renderURL(
ControllerContext controllerContext,
InvokePortletCommandFactory factory,
@@ -336,8 +335,6 @@
{
return new InvokePortletWindowResourceCommand(
window.getId(),
- resourceURL.getMode(),
- resourceURL.getWindowState(),
resourceURL.getCacheability(),
resourceURL.getResourceId(),
resourceURL.getResourceState(),
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
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.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.command.view.ViewContextCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
@@ -78,7 +79,7 @@
ParameterMap queryParams = invocation.getServerContext().getQueryParameterMap();
//
- ControllerCommand cmd = null;
+ ControllerCommand cmd;
if (target instanceof Window)
{
Window window = (Window)target;
@@ -87,41 +88,55 @@
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(queryParams,
invocation.getServerContext().getBodyParameterMap());
- // Get the window navigational state
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
- WindowNavigationalState windowNavState =
(WindowNavigationalState)controllerContext.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey);
- if (windowNavState == null)
+ if (decoder.getType() == PortletRequestDecoder.RESOURCE_TYPE)
{
- windowNavState = WindowNavigationalState.create();
- controllerContext.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey, windowNavState);
+ cmd = new InvokePortletWindowResourceCommand(
+ window.getId(),
+ decoder.getCacheability(),
+ decoder.getResourceId(),
+ decoder.getResourceState(),
+ decoder.getForm());
}
-
- //
- WindowState windowState = decoder.getWindowState();
- if (windowState == null)
+ else
{
- windowState = windowNavState.getWindowState();
- }
+ // Get the window navigational state
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ WindowNavigationalState windowNavState =
(WindowNavigationalState)controllerContext.getAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey);
+ if (windowNavState == null)
+ {
+ windowNavState = WindowNavigationalState.create();
+ controllerContext.setAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey, windowNavState);
+ }
- //
- Mode mode = decoder.getMode();
- if (mode == null)
- {
- mode = windowNavState.getMode();
- }
+ //
+ WindowState windowState = decoder.getWindowState();
+ if (windowState == null)
+ {
+ windowState = windowNavState.getWindowState();
+ }
- //
- switch (decoder.getType())
- {
- case PortletRequestDecoder.NAV_TYPE:
- cmd = new InvokePortletWindowRenderCommand(window.getId(), mode,
windowState);
- break;
- case PortletRequestDecoder.ACTION_TYPE:
- cmd = new InvokePortletWindowActionCommand(window.getId(), mode,
windowState, decoder.getNavigationalState(), decoder.getInteractionState(),
decoder.getForm());
- break;
- case PortletRequestDecoder.RENDER_TYPE:
- cmd = new InvokePortletWindowRenderCommand(window.getId(), mode,
windowState, decoder.getNavigationalState());
- break;
+ //
+ Mode mode = decoder.getMode();
+ if (mode == null)
+ {
+ mode = windowNavState.getMode();
+ }
+
+ //
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.NAV_TYPE:
+ cmd = new InvokePortletWindowRenderCommand(window.getId(), mode,
windowState);
+ break;
+ case PortletRequestDecoder.ACTION_TYPE:
+ cmd = new InvokePortletWindowActionCommand(window.getId(), mode,
windowState, decoder.getNavigationalState(), decoder.getInteractionState(),
decoder.getForm());
+ break;
+ case PortletRequestDecoder.RENDER_TYPE:
+ cmd = new InvokePortletWindowRenderCommand(window.getId(), mode,
windowState, decoder.getNavigationalState());
+ break;
+ default:
+ throw new AssertionError();
+ }
}
}
else
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -32,11 +32,14 @@
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.InvokeWindowCommand;
+import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowCommand;
+import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowResourceCommand;
import org.jboss.portal.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPortalCommand;
import org.jboss.portal.core.portlet.PortletRequestEncoder;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.server.AbstractServerURL;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerURL;
@@ -134,24 +137,45 @@
}
else if (cmd instanceof InvokeWindowCommand)
{
- InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
+ InvokeWindowCommand iwCmd = (InvokeWindowCommand)cmd;
- Mode mode = iwaCmd.getMode();
- WindowState windowState = iwaCmd.getWindowState();
+ //
+ PortletRequestEncoder encoder = new
PortletRequestEncoder(url.getParameterMap());
//
- if (iwaCmd instanceof InvokePortletWindowActionCommand)
+ if (cmd instanceof InvokePortletWindowCommand)
{
- StateString interactionState =
((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
- StateString navigationalState =
((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new
PortletRequestEncoder(url.getParameterMap());
- encoder.encodeAction(navigationalState, interactionState, mode,
windowState);
+ InvokePortletWindowCommand ipwCmd = (InvokePortletWindowCommand)iwCmd;
+
+ //
+ Mode mode = ipwCmd.getMode();
+ WindowState windowState = ipwCmd.getWindowState();
+ StateString navigationalState =
((InvokePortletWindowRenderCommand)iwCmd).getNavigationalState();
+
+ //
+ if (iwCmd instanceof InvokePortletWindowActionCommand)
+ {
+ StateString interactionState =
((InvokePortletWindowActionCommand)iwCmd).getInteractionState();
+
+ //
+ encoder.encodeAction(navigationalState, interactionState, mode,
windowState);
+ }
+ else
+ {
+ encoder.encodeRender(navigationalState, mode, windowState);
+ }
}
else
{
- StateString navigationalState =
((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new
PortletRequestEncoder(url.getParameterMap());
- encoder.encodeRender(navigationalState, mode, windowState);
+ InvokePortletWindowResourceCommand ipwrCmd =
(InvokePortletWindowResourceCommand)iwCmd;
+
+ //
+ StateString resourceState = ipwrCmd.getResourceState();
+ String resourceId = ipwrCmd.getResourceId();
+ CacheLevel cacheability = ipwrCmd.getCacheability();
+
+ //
+ encoder.encodeResource(cacheability, resourceId, resourceState);
}
}
else if (cmd instanceof ImportPageToDashboardCommand)
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-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -43,7 +43,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class InvokePortletWindowActionCommand extends InvokeWindowCommand
+public class InvokePortletWindowActionCommand extends InvokePortletWindowCommand
{
/** . */
private static final CommandInfo info = new ActionCommandInfo(false);
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowCommand.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class InvokePortletWindowCommand extends InvokeWindowCommand
+{
+
+ /** . */
+ protected final Mode mode;
+
+ /** . */
+ protected final WindowState windowState;
+
+ protected InvokePortletWindowCommand(PortalObjectId windowId, Mode mode, WindowState
windowState)
+ throws IllegalArgumentException
+ {
+ super(windowId);
+
+ //
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+}
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-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -41,7 +41,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class InvokePortletWindowRenderCommand extends InvokeWindowCommand
+public class InvokePortletWindowRenderCommand extends InvokePortletWindowCommand
{
/** . */
Modified:
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 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowResourceCommand.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -25,8 +25,6 @@
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;
@@ -46,7 +44,7 @@
private static final CommandInfo info = new ActionCommandInfo(true);
/** . */
- private final CacheLevel cacheLevel;
+ private final CacheLevel cacheability;
/** . */
private final String resourceId;
@@ -59,22 +57,41 @@
public InvokePortletWindowResourceCommand(
PortalObjectId windowId,
- Mode mode,
- WindowState windowState,
- CacheLevel cacheLevel,
+ CacheLevel cacheability,
String resourceId,
StateString resourceState,
ParameterMap resourceForm) throws IllegalArgumentException
{
- super(windowId, mode, windowState);
+ super(windowId);
//
- this.cacheLevel = cacheLevel;
+ if (cacheability == null)
+ {
+ throw new IllegalArgumentException("No null cache level accepted");
+ }
+
+ //
+ this.cacheability = cacheability;
this.resourceId = resourceId;
this.resourceState = resourceState;
this.resourceForm = resourceForm;
}
+ public CacheLevel getCacheability()
+ {
+ return cacheability;
+ }
+
+ public String getResourceId()
+ {
+ return resourceId;
+ }
+
+ public StateString getResourceState()
+ {
+ return resourceState;
+ }
+
public CommandInfo getInfo()
{
return info;
@@ -83,7 +100,9 @@
protected ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
PortletResourceRequest.Scope scope;
- switch (cacheLevel)
+
+ //
+ switch (cacheability)
{
case FULL:
scope = new PortletResourceRequest.FullScope();
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-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-12
14:59:26 UTC (rev 10551)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.PortletResponse;
+import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
@@ -48,31 +49,11 @@
public abstract class InvokeWindowCommand extends WindowCommand
{
- /** . */
- protected final Mode mode;
-
- /** . */
- protected final WindowState windowState;
-
- public InvokeWindowCommand(PortalObjectId windowId, Mode mode, WindowState
windowState) throws IllegalArgumentException
+ public InvokeWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
{
super(windowId);
-
- //
- this.mode = mode;
- this.windowState = windowState;
}
- public Mode getMode()
- {
- return mode;
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
protected abstract ContainerRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS);
public ControllerResponse execute() throws ControllerException
@@ -114,13 +95,20 @@
//
return new UpdatePageResponse(page.getId());
}
- else
+ else if (cr instanceof PortletResponse)
{
PortletResponse portletResponse = (PortletResponse)cr;
//
return ControllerResponseFactory.createActionResponse(targetId,
portletResponse.getResponse());
}
+ else
+ {
+ ResourceResponse resourceResponse = (ResourceResponse)cr;
+
+ //
+ return ControllerResponseFactory.createActionResponse(targetId,
resourceResponse.getResponse());
+ }
}
catch (PortletInvokerException e)
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/default-object.xml 2008-04-12
14:59:26 UTC (rev 10551)
@@ -66,6 +66,12 @@
<region>center</region>
<height>4</height>
</window>
+ <window>
+ <window-name>RemoteControlPortletWindow</window-name>
+ <instance-ref>RemoteControlPortletInstance</instance-ref>
+ <region>center</region>
+ <height>5</height>
+ </window>
</page>
</deployment>
</deployments>
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet-instances.xml 2008-04-12
14:59:26 UTC (rev 10551)
@@ -41,4 +41,11 @@
<portlet-ref>GoogleWeather</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <display-name xml:lang="en">Remote
Controler</display-name>
+ <instance-id>RemoteControlPortletInstance</instance-id>
+ <portlet-ref>RemoteControl</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml 2008-04-12
13:54:23 UTC (rev 10550)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/resources/portal-portlet-samples-war/WEB-INF/portlet.xml 2008-04-12
14:59:26 UTC (rev 10551)
@@ -94,6 +94,29 @@
</portlet>
<portlet>
+ <description>Portlet controlling display of other
portlets</description>
+ <portlet-name>RemoteControl</portlet-name>
+ <display-name>Remote Control Portlet</display-name>
+
<portlet-class>org.jboss.portal.portlet.samples.remotecontroller.RemoteControllerPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Remote Control Portlet</title>
+ <keywords>sample,resource,remotecontrol</keywords>
+ </portlet-info>
+ <portlet-preferences>
+ <preference>
+ <name>color</name>
+ <value>ffe</value>
+ <read-only>false</read-only>
+ </preference>
+ </portlet-preferences>
+
<supported-public-render-parameter>zipcode</supported-public-render-parameter>
+ </portlet>
+
+ <portlet>
<description>Cart Portlet</description>
<portlet-name>Cart</portlet-name>
<display-name>Cart Portlet</display-name>
@@ -121,9 +144,4 @@
<qname
xmlns:g="urn:jboss:portal:simple:google">g:zipcode</qname>
</public-render-parameter>
- <public-render-parameter>
- <identifier>zipcode</identifier>
- <qname
xmlns:g="urn:jboss:portal:simple:google">g:zipcode</qname>
- </public-render-parameter>
-
</portlet-app>