Author: julien(a)jboss.com
Date: 2008-04-11 15:47:42 -0400 (Fri, 11 Apr 2008)
New Revision: 10537
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.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:
work on integrating portlet controller with 2.7
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-04-11
19:12:09 UTC (rev 10536)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2008-04-11
19:47:42 UTC (rev 10537)
@@ -75,6 +75,26 @@
this.updates = new HashMap<String, WindowNavigationalState>(that.updates);
}
+ /**
+ * Flush all updates to the navigational state context.
+ */
+ public void flushUpdates()
+ {
+ for (Map.Entry<String, WindowNavigationalState> entry : updates.entrySet())
+ {
+ Window window = windows.get(entry.getKey());
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = new
org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(
+ entry.getValue().getWindowState(),
+ entry.getValue().getMode(),
+ entry.getValue().getPortletNavigationalState());
+ navigationalStateContext.setWindowNavigationalState(window.getId().toString(),
wns);
+ }
+
+ //
+ updates.clear();
+ }
+
+
public Set<String> getWindowIds()
{
return windows.keySet();
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
19:12:09 UTC (rev 10536)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-11
19:47:42 UTC (rev 10537)
@@ -25,27 +25,19 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.NoSuchResourceException;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.portlet.ControllerResponseFactory;
-import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.identity.User;
-import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.controller.PortletController;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
-import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
-import org.jboss.portal.portlet.controller.response.PortletResponse;
+import org.jboss.portal.portlet.controller.request.PortletRequest;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -146,69 +138,14 @@
return context.getController().getCustomizationManager().getInstance(window,
user);
}
- public ControllerResponse execute() throws ControllerException
+ protected PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
- try
- {
- ControllerPortletControllerContext cpcc = new
ControllerPortletControllerContext(
- context,
- page,
- context.getController().getInstanceContainer()
- );
-
- //
- PageNavigationalState pageNS =
cpcc.getStateControllerContext().createPageNavigationalState(false);
-
- //
- WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(window.getName());
-
- //
- PortletActionRequest actionRequest = new PortletActionRequest(
- window.getName(),
- interactionState,
- formParameters,
- windowNS,
- pageNS
- );
-
- //
- PortletController controller = new PortletController();
-
- //
- org.jboss.portal.portlet.controller.response.ControllerResponse cr =
controller.process(cpcc, actionRequest);
-
- //
- if (cr instanceof PageUpdateResponse)
- {
- PageUpdateResponse pageUpdate = (PageUpdateResponse)cr;
-
- //
- PageNavigationalState pageNavigationalState =
pageUpdate.getPageNavigationalState();
-
- //
- WindowNavigationalState windowNavigationalState =
pageNavigationalState.getWindowNavigationalState(window.getName());
-
- // Julien : this will not work with several portlets updated, either update
directly the
- // nav state of all portlets or put all the nav state in the URL !!!!
- UpdateNavigationalStateResponse windowUpdate = new
UpdateNavigationalStateResponse();
- windowUpdate.setMode(windowNavigationalState.getMode());
- windowUpdate.setWindowState(windowNavigationalState.getWindowState());
-
windowUpdate.setNavigationalState(windowNavigationalState.getPortletNavigationalState());
-
- //
- return ControllerResponseFactory.createActionResponse(targetId,
windowUpdate);
- }
- else
- {
- PortletResponse portletResponse = (PortletResponse)cr;
-
- //
- return ControllerResponseFactory.createActionResponse(targetId,
portletResponse.getResponse());
- }
- }
- catch (PortletInvokerException e)
- {
- return ControllerResponseFactory.createResponse(e);
- }
+ return new PortletActionRequest(
+ window.getName(),
+ interactionState,
+ formParameters,
+ windowNS,
+ pageNS
+ );
}
}
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
19:12:09 UTC (rev 10536)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowRenderCommand.java 2008-04-11
19:47:42 UTC (rev 10537)
@@ -24,17 +24,17 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.invocation.InvocationContext;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
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.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import java.util.HashMap;
+
/**
* Simply update the navigational state of the window. No invocation to the underlying is
done.
*
@@ -57,6 +57,8 @@
throws IllegalArgumentException
{
super(windowId, mode, windowState);
+
+ //
this.navigationalState = navigationalState;
}
@@ -67,6 +69,8 @@
throws IllegalArgumentException
{
super(windowId, mode, windowState);
+
+ //
this.navigationalState = null;
}
@@ -80,22 +84,40 @@
return info;
}
- public ControllerResponse execute() throws InvocationException
+ protected PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS)
{
- InvocationContext ctx = getContext();
- PortalObjectId windowId = window.getId();
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, windowId);
+ Mode newMode = null;
+ WindowState newWindowState = null;
+ StateString newNavigationalState = null;
- // Get old NS
- WindowNavigationalState oldNS =
(WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey);
+ //
+ if (windowNS != null)
+ {
+ newMode = windowNS.getMode();
+ newWindowState = windowNS.getWindowState();
+ newNavigationalState = windowNS.getPortletNavigationalState();
+ }
- // Create new NS
- WindowNavigationalState newNS = WindowNavigationalState.bilto(oldNS,
this.windowState, this.mode, this.navigationalState);
+ //
+ if (mode != null)
+ {
+ newMode = mode;
+ }
+ if (windowState != null)
+ {
+ newWindowState = windowState;
+ }
+ if (navigationalState != null)
+ {
+ newNavigationalState = navigationalState;
+ }
- // Update NS
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey, newNS);
-
//
- return new UpdateWindowResponse(windowId);
+ return new PortletRenderRequest(
+ window.getName(),
+ new WindowNavigationalState(newNavigationalState, newMode, newWindowState),
+ new HashMap<String, String[]>(),
+ pageNS
+ );
}
}
\ No newline at end of file
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
19:12:09 UTC (rev 10536)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokeWindowCommand.java 2008-04-11
19:47:42 UTC (rev 10537)
@@ -24,8 +24,21 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+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.PortletController;
+import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
+import org.jboss.portal.portlet.controller.response.PortletResponse;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
+import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.portlet.ControllerPortletControllerContext;
+import org.jboss.portal.core.controller.portlet.ControllerResponseFactory;
+import org.jboss.portal.core.controller.portlet.ControllerPageNavigationalState;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -58,4 +71,59 @@
{
return windowState;
}
+
+ protected abstract PortletRequest createPortletRequest(PageNavigationalState pageNS,
WindowNavigationalState windowNS);
+
+ public ControllerResponse execute() throws ControllerException
+ {
+ try
+ {
+ ControllerPortletControllerContext cpcc = new
ControllerPortletControllerContext(
+ context,
+ page,
+ context.getController().getInstanceContainer()
+ );
+
+ //
+ PageNavigationalState pageNS =
cpcc.getStateControllerContext().createPageNavigationalState(false);
+
+ //
+ WindowNavigationalState windowNS =
pageNS.getWindowNavigationalState(window.getName());
+
+ //
+ PortletRequest portletRequest = createPortletRequest(pageNS, windowNS);
+
+ //
+ PortletController controller = new PortletController();
+
+ //
+ org.jboss.portal.portlet.controller.response.ControllerResponse cr =
controller.process(cpcc, portletRequest);
+
+ //
+ if (cr instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)cr;
+
+ //
+ ControllerPageNavigationalState pageNavigationalState =
(ControllerPageNavigationalState)pageUpdate.getPageNavigationalState();
+
+ // Flush all NS
+ pageNavigationalState.flushUpdates();
+
+ //
+ return new UpdatePageResponse(page.getId());
+ }
+ else
+ {
+ PortletResponse portletResponse = (PortletResponse)cr;
+
+ //
+ return ControllerResponseFactory.createActionResponse(targetId,
portletResponse.getResponse());
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ return ControllerResponseFactory.createResponse(e);
+ }
+ }
}