JBoss Portal SVN: r10537 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: model/portal/command/action and 1 other directory.
by portal-commits@lists.jboss.org
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);
+ }
+ }
}
18 years
JBoss Portal SVN: r10536 - in branches/JBoss_Portal_Branch_2_7/core: src/main/org/jboss/portal/core/controller/portlet and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-11 15:12:09 -0400 (Fri, 11 Apr 2008)
New Revision: 10536
Added:
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/ControllerPortletControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerStateControllerContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/CoreEventControllerContext.java
Modified:
branches/JBoss_Portal_Branch_2_7/core/build.xml
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/command/action/InvokePortletWindowActionCommand.java
Log:
work on integrating portlet controller with 2.7
Modified: branches/JBoss_Portal_Branch_2_7/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/build.xml 2008-04-11 13:49:20 UTC (rev 10535)
+++ branches/JBoss_Portal_Branch_2_7/core/build.xml 2008-04-11 19:12:09 UTC (rev 10536)
@@ -327,6 +327,7 @@
<include name="portal-portlet-federation-lib.jar"/>
<include name="portal-portlet-management-lib.jar"/>
<include name="portal-portlet-bridge-lib.jar"/>
+ <include name="portal-portlet-controller-lib.jar"/>
</fileset>
<fileset dir="${portlet.portlet.lib}" includes="portlet-api.jar"/>
<fileset dir="${jboss.portal/modules/identity.root}/lib" includes="portal-identity-lib.jar"/>
Added: 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 (rev 0)
+++ 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)
@@ -0,0 +1,169 @@
+/******************************************************************************
+ * 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.controller.portlet;
+
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
+import org.jboss.portal.core.model.portal.Window;
+
+import javax.xml.namespace.QName;
+import java.util.Set;
+import java.util.Collections;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ControllerPageNavigationalState implements PageNavigationalState
+{
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ private final Map<String, Window> windows;
+
+ /** . */
+ private final boolean mutable;
+
+ /** . */
+ private final Map<String, WindowNavigationalState> updates;
+
+ public ControllerPageNavigationalState(
+ NavigationalStateContext navigationalStateContext,
+ Map<String, Window> windows,
+ boolean mutable)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.windows = windows;
+ this.mutable = mutable;
+ this.updates = new HashMap<String, WindowNavigationalState>();
+ }
+
+ public ControllerPageNavigationalState(
+ ControllerPageNavigationalState that,
+ boolean mutable)
+ {
+ this.navigationalStateContext = that.navigationalStateContext;
+ this.windows = new HashMap<String, Window>(that.windows);
+ this.mutable = mutable;
+ this.updates = new HashMap<String, WindowNavigationalState>(that.updates);
+ }
+
+ public Set<String> getWindowIds()
+ {
+ return windows.keySet();
+ }
+
+ public WindowNavigationalState getWindowNavigationalState(String s) throws IllegalArgumentException
+ {
+ WindowNavigationalState update = updates.get(s);
+
+ //
+ if (update != null)
+ {
+ return update;
+ }
+
+ //
+ Window window = windows.get(s);
+
+ //
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = navigationalStateContext.getWindowNavigationalState(window.getId().toString());
+
+ //
+ if (wns == null)
+ {
+ return null;
+ }
+
+ //
+ return new WindowNavigationalState(wns.getContentState(), wns.getMode(), wns.getWindowState());
+ }
+
+ public void setWindowNavigationalState(String s, WindowNavigationalState windowNavigationalState) throws IllegalArgumentException, IllegalStateException
+ {
+ if (!mutable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ updates.put(s, windowNavigationalState);
+
+ //
+// Window window = windows.get(s);
+//
+// //
+// org.jboss.portal.core.model.portal.navstate.WindowNavigationalState wns = new org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(
+// windowNavigationalState.getWindowState(),
+// windowNavigationalState.getMode(),
+// windowNavigationalState.getPortletNavigationalState()
+// );
+//
+// //
+// navigationalStateContext.setWindowNavigationalState(window.getId().toString(), wns);
+ }
+
+ public ParameterMap getPublicNavigationalState(String s) throws IllegalArgumentException
+ {
+ return new ParameterMap();
+ }
+
+ public Set<QName> getPublicNames()
+ {
+ return Collections.emptySet();
+ }
+
+ public String[] getPublicNavigationalState(QName qName) throws IllegalArgumentException
+ {
+ return new String[0];
+ }
+
+ public void setPublicNavigationalState(QName qName, String[] strings) throws IllegalArgumentException, IllegalStateException
+ {
+ if (!mutable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ throw new NotYetImplemented();
+ }
+
+ public void removePublicNavigationalState(QName qName) throws IllegalArgumentException, IllegalStateException
+ {
+ if (!mutable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ throw new NotYetImplemented();
+ }
+}
Added: 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 (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPortletControllerContext.java 2008-04-11 19:12:09 UTC (rev 10536)
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * 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.controller.portlet;
+
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
+import org.jboss.portal.common.NotYetImplemented;
+
+import javax.servlet.http.Cookie;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ControllerPortletControllerContext implements PortletControllerContext
+{
+
+ /** . */
+ private final ControllerContext controllerContext;
+
+ /** A map of window name -> portlet info. */
+ private final Map<String, PortletInfo> infos;
+
+ /** A map of window name -> window. */
+ private final Map<String, Window> windows;
+
+ /** A map of window name -> portlet info. */
+ private final Map<String, Instance> instances;
+
+ /** . */
+ private final ControllerStateControllerContext stateControllerContext;
+
+ /** . */
+ private final CoreEventControllerContext eventControllerContext;
+
+ public ControllerPortletControllerContext(
+ ControllerContext controllerContext,
+ Page page,
+ InstanceContainer instanceContainer)
+ {
+ Map<String, PortletInfo> infos = new HashMap<String, PortletInfo>();
+ Map<String, Instance> instances = new HashMap<String, Instance>();
+ Map<String, Window> windows = new HashMap<String, Window>();
+
+ //
+ for (PortalObject child : page.getChildren(PortalObject.WINDOW_MASK))
+ {
+ Window window = (Window)child;
+
+ //
+ Content content = window.getContent();
+
+ //
+ if (content instanceof PortletContent)
+ {
+ PortletContent portletContent = (PortletContent)content;
+
+ //
+ String instanceRef = portletContent.getInstanceRef();
+ Instance instance = instanceContainer.getDefinition(instanceRef);
+
+ //
+ if (instance != null)
+ {
+ try
+ {
+ Portlet portlet = instance.getPortlet();
+ infos.put(window.getName(), portlet.getInfo());
+ instances.put(window.getName(), instance);
+ windows.put(window.getName(), window);
+ }
+ catch (PortletInvokerException ignore)
+ {
+ }
+ }
+ }
+ }
+
+ // State controller context
+ NavigationalStateContext nsContext = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ //
+ this.stateControllerContext = new ControllerStateControllerContext(nsContext, windows);
+ this.eventControllerContext = new CoreEventControllerContext();
+ this.controllerContext = controllerContext;
+ this.windows = windows;
+ this.infos = infos;
+ this.instances = instances;
+ }
+
+ public PortletInfo getPortletInfo(String windowId)
+ {
+ return infos.get(windowId);
+ }
+
+ public PortletInvocationContext createPortletInvocationContext(String s, PageNavigationalState pageNavigationalState)
+ {
+ Window window = windows.get(s);
+
+ //
+ return PortletInvocationFactory.createInvocationContext(controllerContext, window);
+ }
+
+ public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws PortletInvokerException
+ {
+ PortletInvocationFactory.contextualizeAction(actionInvocation);
+
+ //
+ Window window = PortletInvocationFactory.getTargetWindow(actionInvocation);
+
+ //
+ Instance instance = instances.get(window.getName());
+
+ //
+ return instance.invoke(actionInvocation);
+ }
+
+ public PortletInvocationResponse invoke(List<Cookie> cookies, EventInvocation eventInvocation) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
+
+ public StateControllerContext getStateControllerContext()
+ {
+ return stateControllerContext;
+ }
+}
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerStateControllerContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerStateControllerContext.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerStateControllerContext.java 2008-04-11 19:12:09 UTC (rev 10536)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.controller.portlet;
+
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ControllerStateControllerContext implements StateControllerContext
+{
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ private final Map<String, Window> windows;
+
+ public ControllerStateControllerContext(NavigationalStateContext navigationalStateContext, Map<String, Window> windows)
+ {
+ this.navigationalStateContext = navigationalStateContext;
+ this.windows = windows;
+ }
+
+ public PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean mutable)
+ {
+ return new ControllerPageNavigationalState((ControllerPageNavigationalState)pageNavigationalState, mutable);
+ }
+
+ public PageNavigationalState createPageNavigationalState(boolean mutable)
+ {
+ return new ControllerPageNavigationalState(navigationalStateContext, windows, mutable);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/CoreEventControllerContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/CoreEventControllerContext.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/CoreEventControllerContext.java 2008-04-11 19:12:09 UTC (rev 10536)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.controller.portlet;
+
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.event.EventPhaseContext;
+import org.jboss.portal.portlet.controller.event.Event;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.common.NotYetImplemented;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class CoreEventControllerContext implements EventControllerContext
+{
+ public void eventProduced(EventPhaseContext eventPhaseContext, Event event, Event event1)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void eventConsumed(EventPhaseContext eventPhaseContext, Event event, PortletInvocationResponse portletInvocationResponse)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void eventFailed(EventPhaseContext eventPhaseContext, Event event, Throwable throwable)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public void eventDiscarded(EventPhaseContext eventPhaseContext, Event event, int i)
+ {
+ throw new NotYetImplemented();
+ }
+}
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 13:49:20 UTC (rev 10535)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-04-11 19:12:09 UTC (rev 10536)
@@ -59,6 +59,23 @@
public static ThreadLocal<UserContext> userContextTL = new ThreadLocal<UserContext>();
+ public static InvokePortletCommandFactory createInvokePortletCommandFactory(ControllerContext controllerContext, Window window)
+ {
+ return new InternalInvokePortletCommandFactory(window, controllerContext);
+ }
+
+ public static PortletInvocationContext createInvocationContext(ControllerContext controllerContext, InvokePortletCommandFactory cpc)
+ {
+ MarkupInfo markupInfo = (MarkupInfo)controllerContext.getServerInvocation().getResponse().getContentInfo();
+ return new ControllerPortletInvocationContext(cpc, controllerContext, markupInfo);
+ }
+
+ public static PortletInvocationContext createInvocationContext(ControllerContext controllerContext, Window window)
+ {
+ InvokePortletCommandFactory ipcf = createInvokePortletCommandFactory(controllerContext, window);
+ return createInvocationContext(controllerContext, ipcf);
+ }
+
public static RenderInvocation createRender(
ControllerContext controllerContext,
Mode mode,
@@ -68,11 +85,10 @@
Portal portal)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
- InternalInvokePortletCommandFactory cpc = new InternalInvokePortletCommandFactory(window, controllerContext);
+ InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
return createRender(controllerContext, mode, windowState, navigationalState, cf, cpc);
}
-
public static ActionInvocation createAction(
ControllerContext controllerContext,
Mode mode,
@@ -84,7 +100,7 @@
Portal portal)
{
PortletContextFactory cf = new PortletContextFactory(controllerContext, portal, window);
- InternalInvokePortletCommandFactory cpc = new InternalInvokePortletCommandFactory(window, controllerContext);
+ InvokePortletCommandFactory cpc = createInvokePortletCommandFactory(controllerContext, window);
return createAction(controllerContext, mode, windowState, navigationalState, interactionState, form, cf, cpc);
}
@@ -98,33 +114,20 @@
PortletContextFactory cf,
InvokePortletCommandFactory cpc)
{
- MarkupInfo markupInfo = (MarkupInfo)controllerContext.getServerInvocation().getResponse().getContentInfo();
-
- PortletInvocationContext portletInvocationContext = new ControllerPortletInvocationContext(cpc, controllerContext, mode, windowState, navigationalState, markupInfo);
+ PortletInvocationContext portletInvocationContext = createInvocationContext(controllerContext, cpc);
//
ActionInvocation action = new ActionInvocation(portletInvocationContext);
-
+
+ //
action.setForm(form);
action.setMode(mode);
action.setWindowState(windowState);
action.setNavigationalState(navigationalState);
action.setInteractionState(interactionState);
-
- 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());
+ contextualizeAction(controllerContext, cf, action);
//
return action;
@@ -138,26 +141,34 @@
PortletContextFactory cf,
InvokePortletCommandFactory cpc)
{
- MarkupInfo markupInfo = (MarkupInfo)controllerContext.getServerInvocation().getResponse().getContentInfo();
+ PortletInvocationContext portletInvocationContext = createInvocationContext(controllerContext, cpc);
- PortletInvocationContext portletInvocationContext = new ControllerPortletInvocationContext(cpc, controllerContext, mode, windowState, navigationalState, markupInfo);
-
//
RenderInvocation render = new RenderInvocation(portletInvocationContext);
+ //
render.setMode(mode);
render.setWindowState(windowState);
render.setNavigationalState(navigationalState);
//
+ return contextualizeRender(controllerContext, cf, render);
+ }
+
+ public static RenderInvocation contextualizeRender(
+ ControllerContext controllerContext,
+ PortletContextFactory cf,
+ RenderInvocation render)
+ {
render.setAttribute(PortletInvocation.INVOCATION_SCOPE, "controller_context", controllerContext);
-
+
+ //
UserContext userContext = cf.createUserContext();
//
controllerContextTL.set(controllerContext);
userContextTL.set(userContext);
-
+
// Contextualize
render.setSecurityContext(cf.createSecurityContext());
render.setPortalContext(cf.createPortalContext());
@@ -165,48 +176,46 @@
render.setUserContext(cf.createUserContext());
render.setServerContext(cf.createServerContext());
render.setClientContext(cf.createClientContext());
+
//
return render;
}
- public static class ControllerPortletInvocationContext extends AbstractPortletInvocationContext
+ public static Window getTargetWindow(ActionInvocation action)
{
- private InvokePortletCommandFactory cmdFactory;
- private ControllerContext controllerContext;
+ ControllerPortletInvocationContext cpic = (ControllerPortletInvocationContext)action.getContext();
+ InternalInvokePortletCommandFactory iipcf = (InternalInvokePortletCommandFactory)cpic.cmdFactory;
+ return iipcf.window;
+ }
- public ControllerPortletInvocationContext(InvokePortletCommandFactory cmdFactory, ControllerContext controllerContext, Mode mode, WindowState windowState, StateString navigationalState, MarkupInfo markupInfo)
- {
- super(markupInfo);
+ public static void contextualizeAction(ActionInvocation action)
+ {
+ ControllerPortletInvocationContext cpic = (ControllerPortletInvocationContext)action.getContext();
+ Window window = getTargetWindow(action);
+ contextualizeAction(cpic.controllerContext, new PortletContextFactory(cpic.controllerContext, window.getPage().getPortal(), window), action);
+ }
- //
- this.cmdFactory = cmdFactory;
- this.controllerContext = controllerContext;
+ public static void contextualizeAction(
+ ControllerContext controllerContext,
+ PortletContextFactory cf,
+ ActionInvocation action)
+ {
+ UserContext userContext = cf.createUserContext();
- //
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
-// addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
-// addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
- }
+ //
+ controllerContextTL.set(controllerContext);
+ userContextTL.set(userContext);
- public HttpServletRequest getClientRequest() throws IllegalStateException
- {
- return controllerContext.getServerInvocation().getServerContext().getClientRequest();
- }
-
- public HttpServletResponse getClientResponse() throws IllegalStateException
- {
- return controllerContext.getServerInvocation().getServerContext().getClientResponse();
- }
-
- public String renderURL(ContainerURL containerURL, org.jboss.portal.portlet.URLFormat urlFormat)
- {
- return PortletInvocationFactory.renderURL(controllerContext, cmdFactory, containerURL, urlFormat.getWantSecure(), urlFormat.getWantAuthenticated(), urlFormat.getWantRelative());
- }
+ // 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,
@@ -243,6 +252,48 @@
return controllerContext.renderURL(cmd, info, URLFormat.newInstance(relative, true));
}
+ public static class ControllerPortletInvocationContext extends AbstractPortletInvocationContext
+ {
+
+ /** . */
+ private InvokePortletCommandFactory cmdFactory;
+
+ /** . */
+ private ControllerContext controllerContext;
+
+ public ControllerPortletInvocationContext(
+ InvokePortletCommandFactory cmdFactory,
+ ControllerContext controllerContext,
+ MarkupInfo markupInfo)
+ {
+ super(markupInfo);
+
+ //
+ this.cmdFactory = cmdFactory;
+ this.controllerContext = controllerContext;
+
+ //
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, controllerContext);
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, controllerContext);
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientRequest();
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return controllerContext.getServerInvocation().getServerContext().getClientResponse();
+ }
+
+ public String renderURL(ContainerURL containerURL, org.jboss.portal.portlet.URLFormat urlFormat)
+ {
+ return PortletInvocationFactory.renderURL(controllerContext, cmdFactory, containerURL, urlFormat.getWantSecure(), urlFormat.getWantAuthenticated(), urlFormat.getWantRelative());
+ }
+ }
+
private static class InternalInvokePortletCommandFactory implements InvokePortletCommandFactory
{
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 13:49:20 UTC (rev 10535)
+++ 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)
@@ -24,63 +24,29 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.io.Serialization;
-import org.jboss.portal.common.io.SerializationFilter;
-import org.jboss.portal.common.util.Base64;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.core.controller.ControllerCommand;
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.command.response.RedirectionResponse;
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.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
-import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.identity.User;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.portlet.controller.PortletController;
-import org.jboss.portal.portlet.controller.PortletControllerContext;
-import org.jboss.portal.portlet.controller.event.EventControllerContext;
-import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
-import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
-import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
-import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
-import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
-import org.jboss.portal.portlet.controller.request.ControllerRequest;
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.response.ResourceResponse;
-import org.jboss.portal.portlet.controller.state.AbstractPageNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.web.IllegalRequestException;
-import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.Set;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -184,309 +150,65 @@
{
try
{
- // State controller context
- NavigationalStateContext nsContext = (NavigationalStateContext)context.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ ControllerPortletControllerContext cpcc = new ControllerPortletControllerContext(
+ context,
+ page,
+ context.getController().getInstanceContainer()
+ );
- ActionStateControllerContext stateControllerContext = new ActionStateControllerContext(nsContext);
+ //
+ PageNavigationalState pageNS = cpcc.getStateControllerContext().createPageNavigationalState(false);
- // Portlet controller context
- PortletControllerContext controllerContext;
- HttpServletRequest clientRequest = context.getServerInvocation().getServerContext().getClientRequest();
- HttpServletResponse clientResponse = context.getServerInvocation().getServerContext().getClientResponse();
- try
- {
- controllerContext = new ActionPortletControllerContext(clientRequest, clientResponse, stateControllerContext);
- }
- catch (IOException e)
- {
- throw new ControllerException("Couldn't create PortletControllerContext!", e);
- }
+ //
+ WindowNavigationalState windowNS = pageNS.getWindowNavigationalState(window.getName());
- // The type of invocation
- String type = (String)clientRequest.getAttribute(URLParameterConstants.TYPE);
+ //
+ PortletActionRequest actionRequest = new PortletActionRequest(
+ window.getName(),
+ interactionState,
+ formParameters,
+ windowNS,
+ pageNS
+ );
- // Process only portlet type
- // The request decoded if not null
- PageNavigationalState pageNavigationalState = null;
- if (URLParameterConstants.PORTLET_TYPE.equals(type))
- {
- WebRequest wr;
- try
- {
- wr = new WebRequest(clientRequest);
- }
- catch (UnsupportedEncodingException e)
- {
- throw new ControllerException("Couldn't create web request!", e);
- }
+ //
+ PortletController controller = new PortletController();
- PageNavigationalStateSerialization stateSerialization = new PageNavigationalStateSerialization(stateControllerContext);
- ControllerRequestFactory factory = new ControllerRequestFactory(stateSerialization);
- ControllerRequest request = factory.createRequest(wr);
+ //
+ org.jboss.portal.portlet.controller.response.ControllerResponse cr = controller.process(cpcc, actionRequest);
- org.jboss.portal.portlet.controller.response.ControllerResponse controllerResponse;
- controllerResponse = new PortletController().process(controllerContext, request);
+ //
+ if (cr instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)cr;
//
- if (controllerResponse instanceof PageUpdateResponse)
- {
- PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
+ PageNavigationalState pageNavigationalState = pageUpdate.getPageNavigationalState();
- //
- pageNavigationalState = pageUpdate.getPageNavigationalState();
+ //
+ WindowNavigationalState windowNavigationalState = pageNavigationalState.getWindowNavigationalState(window.getName());
- // We perform a send redirect on actions
- if (request instanceof PortletActionRequest)
- {
- PortletURLRenderer renderer = new PortletURLRenderer(pageUpdate.getPageNavigationalState(),
- clientRequest, clientResponse, stateSerialization);
+ // 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());
- //
- String url = renderer.renderURL(new URLFormat(null, null, true, null));
- return new RedirectionResponse(url);
- }
- }
- else if (controllerResponse instanceof ResourceResponse)
- {
- // todo: deal with this later
-
- throw new NotYetImplemented("Resources are not currently supported!");
-
- /* ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
- PortletInvocationResponse pir = resourceResponse.getResponse();
-
- //
- if (pir instanceof ContentResponse)
- {
- ContentResponse contentResponse = (ContentResponse)pir;
-
- //
- if (contentResponse.getType() == ContentResponse.TYPE_EMPTY)
- {
- clientResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
- else
- {
- String contentType = contentResponse.getContentType();
- if (contentType != null)
- {
- clientResponse.setContentType(contentType);
- }
-
- //
- if (contentResponse.getType() == ContentResponse.TYPE_BYTES)
- {
- ServletOutputStream out = null;
- try
- {
- out = clientResponse.getOutputStream();
- out.write(contentResponse.getBytes());
- }
- catch (IOException e)
- {
- throw new ControllerException("Couldn't output bytes!", e);
- }
- finally
- {
- IOTools.safeClose(out);
- }
- }
- else
- {
- Writer writer = null;
- try
- {
- writer = clientResponse.getWriter();
- writer.write(contentResponse.getChars());
- }
- catch (IOException e)
- {
- throw new ControllerException("Couldn't output chars!", e);
- }
- finally
- {
- IOTools.safeClose(writer);
- }
- }
- }
- }
- else
- {
- // todo
- }*/
- }
- else if (controllerResponse instanceof PortletResponse)
- {
- PortletResponse portletResponse = (PortletResponse)controllerResponse;
-
- // Let core deal with the response
- return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse());
-
- }
- else
- {
- throw new PortletInvokerException("Unexpected response type: " + controllerResponse.getClass().getName());
- }
+ //
+ return ControllerResponseFactory.createActionResponse(targetId, windowUpdate);
}
else
{
- PageNavigationalStateSerialization serialization = new PageNavigationalStateSerialization(controllerContext.getStateControllerContext());
- // The nav state provided with the request
- // Unmarshall portal navigational state if it is provided
- pageNavigationalState = null;
- String blah = clientRequest.getParameter(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE);
- if (blah != null)
- {
- byte[] bytes = Base64.decode(blah, true);
- pageNavigationalState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
- }
+ PortletResponse portletResponse = (PortletResponse)cr;
+
+ //
+ return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse());
}
}
catch (PortletInvokerException e)
{
return ControllerResponseFactory.createResponse(e);
}
-
- return new UpdateWindowResponse(targetId);
}
-
- private class ActionPortletControllerContext extends AbstractPortletControllerContext
- {
- private final StateControllerContext stateControllerContext;
-
- public ActionPortletControllerContext(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, ActionStateControllerContext stateControllerContext)
- throws IllegalRequestException, IOException
- {
- super(httpServletRequest, httpServletResponse);
- stateControllerContext.setPortletControllerContext(this);
- this.stateControllerContext = stateControllerContext;
- }
-
- protected Portlet getPortlet(String windowId) throws PortletInvokerException
- {
- PortalObjectId id = PortalObjectId.parse(windowId, PortalObjectPath.CANONICAL_FORMAT);
- PortalObject portalObject = context.getController().getPortalObjectContainer().getObject(id);
- if (portalObject instanceof Window)
- {
- Window window = (Window)portalObject;
- Instance instance = getInstance(window);
- if (instance != null)
- {
- return instance.getPortlet();
- }
- }
-
- return null;
- }
-
- protected PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws PortletInvokerException
- {
- return instance.invoke(portletInvocation);
- }
-
- protected Serialization<PageNavigationalState> getPageNavigationalStateSerialization()
- {
- return new PageNavigationalStateSerialization(stateControllerContext);
- }
-
- public EventControllerContext getEventControllerContext()
- {
- return null;
- }
-
- public StateControllerContext getStateControllerContext()
- {
- return stateControllerContext;
- }
- }
-
- private static class ActionPageNavigationalState extends AbstractPageNavigationalState
- {
- private ActionStateControllerContext controllerContext;
-
- private ActionPageNavigationalState(ActionStateControllerContext controllerContext, boolean modifiable)
- {
- super(modifiable);
- this.controllerContext = controllerContext;
- }
-
- private NavigationalStateContext getNSContext()
- {
- return controllerContext.nsContext;
- }
-
- private PortletControllerContext getPCContext()
- {
- return controllerContext.controllerContext;
- }
-
- public Set<String> getWindowIds()
- {
- return getNSContext().getKeys();
- }
-
- public WindowNavigationalState getWindowNavigationalState(String windowId) throws IllegalArgumentException
- {
- org.jboss.portal.core.model.portal.navstate.WindowNavigationalState coreNS = getNSContext().getWindowNavigationalState(windowId);
-
- if (coreNS != null)
- {
- return new WindowNavigationalState(coreNS.getContentState(), coreNS.getMode(), coreNS.getWindowState());
- }
- else
- {
- return null;
- }
- }
-
- public void setWindowNavigationalState(String windowId, WindowNavigationalState windowNS) throws IllegalArgumentException, IllegalStateException
- {
- if (windowNS != null)
- {
- org.jboss.portal.core.model.portal.navstate.WindowNavigationalState coreNS =
- new org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(windowNS.getWindowState(),
- windowNS.getMode(), windowNS.getPortletNavigationalState());
- getNSContext().setWindowNavigationalState(windowId, coreNS);
- }
- else
- {
- getNSContext().setWindowNavigationalState(windowId, null);
- }
- }
-
- protected PortletInfo getPortletInfo(String windowId)
- {
- return getPCContext().getPortletInfo(windowId);
- }
- }
-
- private static class ActionStateControllerContext implements StateControllerContext
- {
- private PortletControllerContext controllerContext;
- private NavigationalStateContext nsContext;
-
- public ActionStateControllerContext(NavigationalStateContext nsContext)
- {
- this.nsContext = nsContext;
- }
-
- public PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable)
- {
- if (pageNavigationalState != null)
- {
- return new ActionPageNavigationalState(this, modifiable);
- }
- return null;
- }
-
- public PageNavigationalState createPageNavigationalState(boolean modifiable)
- {
- return new ActionPageNavigationalState(this, modifiable);
- }
-
- public void setPortletControllerContext(PortletControllerContext portletControllerContext)
- {
- this.controllerContext = portletControllerContext;
- }
- }
}
18 years
JBoss Portal SVN: r10535 - modules/portlet/trunk/build.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-11 09:49:20 -0400 (Fri, 11 Apr 2008)
New Revision: 10535
Modified:
modules/portlet/trunk/build/pom.xml
Log:
use common and web 1.2.0.Beta3 because it does not work with trunk snapshots for now
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-04-11 13:43:57 UTC (rev 10534)
+++ modules/portlet/trunk/build/pom.xml 2008-04-11 13:49:20 UTC (rev 10535)
@@ -33,8 +33,8 @@
<version.jboss-logging>2.0.3.GA</version.jboss-logging>
<version.jbossxb>2.0.0.CR5</version.jbossxb>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
- <version.jboss.portal.common>1.2.0-SNAPSHOT</version.jboss.portal.common>
- <version.jboss.portal.web>1.2.0-SNAPSHOT</version.jboss.portal.web>
+ <version.jboss.portal.common>1.2.0.Beta3</version.jboss.portal.common>
+ <version.jboss.portal.web>1.2.0.Beta3</version.jboss.portal.web>
<version.jboss.unit>1.2.0.Beta2</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
18 years
JBoss Portal SVN: r10534 - in modules/portlet/trunk: controller/src/main/java/org/jboss/portal/portlet/controller and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-04-11 09:43:57 -0400 (Fri, 11 Apr 2008)
New Revision: 10534
Removed:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java
Modified:
modules/portlet/trunk/build/pom.xml
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java
modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
Log:
revert latest portlet changes as I did a mistake believing I could simplify but it should not be done as it removes flexilibity
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/build/pom.xml 2008-04-11 13:43:57 UTC (rev 10534)
@@ -33,8 +33,8 @@
<version.jboss-logging>2.0.3.GA</version.jboss-logging>
<version.jbossxb>2.0.0.CR5</version.jbossxb>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
- <version.jboss.portal.common>1.2.0.Beta3</version.jboss.portal.common>
- <version.jboss.portal.web>1.2.0.Beta3</version.jboss.portal.web>
+ <version.jboss.portal.common>1.2.0-SNAPSHOT</version.jboss.portal.common>
+ <version.jboss.portal.web>1.2.0-SNAPSHOT</version.jboss.portal.web>
<version.jboss.unit>1.2.0.Beta2</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -33,7 +33,10 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -56,13 +59,13 @@
/**
* Create a portlet invocation context for the specified window id.
*
- * @param windowId the window id
- * @param pageNavigationalState the page navigational state
- * @return a portlet invocation context
+ * @param windowId the window id
+ * @param pageNavigationalState
+ * @return
*/
PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState);
- PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws PortletInvokerException;
+ PortletInvocationResponse invoke( ActionInvocation actionInvocation) throws PortletInvokerException;
PortletInvocationResponse invoke(List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException;
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -29,8 +29,6 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.NavigationInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.controller.event.Event;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
@@ -50,7 +48,6 @@
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import javax.servlet.http.Cookie;
-import javax.xml.namespace.QName;
import java.util.List;
import java.util.Map;
@@ -403,32 +400,10 @@
pageNavigationalState.setWindowNavigationalState(windowId, windowNS);
// Now update shared state scoped at page
- PortletInfo info = context.getPortletInfo(windowId);
- if (info != null)
+ Map<String, String[]> publicNS = update.getPublicNavigationalStateUpdates();
+ if (publicNS != null)
{
- NavigationInfo navigationInfo = info.getNavigation();
- for (Map.Entry<String, String[]> entry : update.getPublicNavigationalStateUpdates().entrySet())
- {
- String id = entry.getKey();
-
- //
- ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
-
- //
- if (parameterInfo != null)
- {
- QName name = parameterInfo.getName();
- String[] value = entry.getValue();
- if (value.length > 0)
- {
- pageNavigationalState.setPublicNavigationalState(name, value);
- }
- else
- {
- pageNavigationalState.removePublicNavigationalState(name);
- }
- }
- }
+ pageNavigationalState.setPublicNavigationalState(windowId, publicNS);
}
}
}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -22,10 +22,14 @@
******************************************************************************/
package org.jboss.portal.portlet.controller.impl.state;
-import org.jboss.portal.portlet.controller.state.AbstractPageNavigationalState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -35,26 +39,35 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PageNavigationalStateImpl extends AbstractPageNavigationalState implements Serializable
+public class PageNavigationalStateImpl implements PageNavigationalState, Serializable
{
+
/** . */
protected final StateControllerContextImpl context;
/** . */
protected final Map<String, WindowNavigationalState> windows;
+ /** . */
+ protected final Map<QName, String[]> page;
+
+ /** . */
+ private final boolean modifiable;
+
protected PageNavigationalStateImpl(StateControllerContextImpl context, boolean modifiable)
{
- super(modifiable);
this.context = context;
this.windows = new HashMap<String, WindowNavigationalState>();
+ this.page = new HashMap<QName, String[]>();
+ this.modifiable = modifiable;
}
public PageNavigationalStateImpl(PageNavigationalStateImpl original, boolean modifiable)
{
- super(modifiable, original.page);
this.context = original.context;
this.windows = new HashMap<String, WindowNavigationalState>(original.windows);
+ this.page = new HashMap<QName, String[]>(original.page);
+ this.modifiable = modifiable;
}
public Set<String> getWindowIds()
@@ -67,6 +80,47 @@
return windows.get(windowId);
}
+ public ParameterMap getPublicNavigationalState(String windowId)
+ {
+ PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
+
+ //
+ if (info != null)
+ {
+ ParameterMap publicNavigationalState = new ParameterMap();
+ for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
+ {
+ String[] parameterValue = page.get(parameterInfo.getName());
+
+ //
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
+ }
+
+ //
+ return publicNavigationalState;
+ }
+
+ //
+ return null;
+ }
+
+ public Set<QName> getPublicNames()
+ {
+ return page.keySet();
+ }
+
+ public String[] getPublicNavigationalState(QName name)
+ {
+ String[] values = page.get(name);
+ return values != null ? values.clone() : null;
+ }
+
public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState)
{
if (!modifiable)
@@ -78,8 +132,64 @@
windows.put(windowId, windowState);
}
- protected PortletInfo getPortletInfo(String windowId)
+ public void setPublicNavigationalState(String windowId, Map<String, String[]> update)
{
- return context.portletControllerContext.getPortletInfo(windowId);
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
+
+ //
+ if (info != null)
+ {
+ NavigationInfo navigationInfo = info.getNavigation();
+ for (Map.Entry<String, String[]> entry : update.entrySet())
+ {
+ String id = entry.getKey();
+
+ //
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
+
+ //
+ if (parameterInfo != null)
+ {
+ QName name = parameterInfo.getName();
+ String[] value = entry.getValue();
+ if (value.length > 0)
+ {
+ setPublicNavigationalState(name, value);
+ }
+ else
+ {
+ removePublicNavigationalState(name);
+ }
+ }
+ }
+ }
}
+
+ public void setPublicNavigationalState(QName name, String[] value)
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ // We clone the value in order to keep the state not mutated by a side effect
+ page.put(name, value.clone());
+ }
+
+ public void removePublicNavigationalState(QName name)
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ page.remove(name);
+ }
}
\ No newline at end of file
Deleted: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -1,120 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.portal.portlet.controller.state;
-
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-
-import javax.xml.namespace.QName;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public abstract class AbstractPageNavigationalState implements PageNavigationalState
-{
- /** . */
- protected final Map<QName, String[]> page;
- /** . */
- protected final boolean modifiable;
-
- protected AbstractPageNavigationalState(boolean modifiable)
- {
- this(modifiable, new HashMap<QName, String[]>());
- }
-
- protected AbstractPageNavigationalState(boolean modifiable, Map<QName, String[]> page)
- {
- this.modifiable = modifiable;
- this.page = page;
- }
-
- public ParameterMap getPublicNavigationalState(String windowId)
- {
- PortletInfo info = getPortletInfo(windowId);
-
- //
- if (info != null)
- {
- ParameterMap publicNavigationalState = new ParameterMap();
- for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
- {
- String[] parameterValue = page.get(parameterInfo.getName());
-
- //
- if (parameterValue != null)
- {
- String parameterId = parameterInfo.getId();
-
- // We clone the value here so we keep the internal state not potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
- }
- }
-
- //
- return publicNavigationalState;
- }
-
- //
- return null;
- }
-
- protected abstract PortletInfo getPortletInfo(String windowId);
-
- public Set<QName> getPublicNames()
- {
- return page.keySet();
- }
-
- public String[] getPublicNavigationalState(QName name)
- {
- String[] values = page.get(name);
- return values != null ? values.clone() : null;
- }
-
- public void setPublicNavigationalState(QName name, String[] value)
- {
- if (!modifiable)
- {
- throw new IllegalStateException("The page navigational state is not modifiable");
- }
-
- // We clone the value in order to keep the state not mutated by a side effect
- page.put(name, value.clone());
- }
-
- public void removePublicNavigationalState(QName name)
- {
- if (!modifiable)
- {
- throw new IllegalStateException("The page navigational state is not modifiable");
- }
-
- //
- page.remove(name);
- }
-}
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.util.ParameterMap;
import javax.xml.namespace.QName;
+import java.util.Map;
import java.util.Set;
/**
@@ -83,6 +84,20 @@
Set<QName> getPublicNames();
/**
+ * Update the public navigational state of a window. The interpretation of what should be updated is left up to the
+ * implementor. An example of implementation would use the mapping between qname and name provided by the referenced
+ * portlet info.
+ * <p/>
+ * The update argument values with a length of zero should be treated as removals.
+ *
+ * @param windowId the window id
+ * @param update the updates
+ * @throws IllegalArgumentException if an argument is not valid
+ * @throws IllegalStateException if the page state is read only
+ */
+ void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws IllegalArgumentException, IllegalStateException;
+
+ /**
* Returns a public navigational state entry or null if it is not found.
*
* @param name the name
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -32,11 +32,10 @@
{
/**
- * Clone an existing page navigational state object.
+ * Clone an existing page state object.
*
- * @param pageNavigationalState the page navigational state to clone
- * @param modifiable set the modifiable status @return the page state clone
- * @return a clone of the provided page navigational state
+ * @param pageNavigationalState
+ *@param modifiable set the modifiable status @return the page state clone
*/
PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable);
Modified: modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java
===================================================================
--- modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -22,24 +22,24 @@
******************************************************************************/
package org.jboss.portal.portlet.portal.admin.ui;
-import org.jboss.portal.portlet.ParametersStateString;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import org.jboss.portal.portlet.portal.jsp.EventAcknowledgement;
-import org.jboss.portal.portlet.portal.jsp.EventRoute;
import org.jboss.portal.portlet.portal.jsp.PageEventControllerContext;
+import org.jboss.portal.portlet.portal.jsp.EventRoute;
import org.jboss.portal.portlet.portal.jsp.PagePortletControllerContext;
+import org.jboss.portal.portlet.portal.jsp.EventAcknowledgement;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.ParametersStateString;
import javax.portlet.GenericPortlet;
-import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Map;
import java.util.Random;
+import java.util.Map;
+import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -70,7 +70,7 @@
int id;
for (EventRoute route : eventCC.getRoots())
{
- id = rand(1, 1000);
+ id = rand(1,1000);
writer.println("<div class=\"event\" id=\"event-" + id + "\">\n");
printRoute(route, writer, context, id, "");
writer.println("</div>\n");
@@ -83,13 +83,13 @@
}
}
- private void printRoute(EventRoute route, PrintWriter writer, PagePortletControllerContext context, int id, String cid)
+ private void printRoute(EventRoute route, PrintWriter writer,PagePortletControllerContext context, int id, String cid)
{
writer.print("<div onmouseover=\"showDetails(this,'details-" + id + cid + "')\" onmouseout=\"hideDetails(this,'details-" + id + cid + "')\" onclick=\"new Effect.Highlight('" + context.getPortletInfo(route.getSource()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'start', scope: 'highlight', limit:2}});new Effect.Highlight('" + context.getPortletInfo(route.getDestination()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'end', scope: 'highlight', limit:2}});\" >" +
"<div class=\"event-header\">\n" +
- " <h4>" + context.getPortletInfo(route.getSource()).getName() + "</h4>\n" +
- " <div>Event: " + route.getName().getLocalPart() + "</div>\n" +
- " </div>\n");
+ " <h4>" + context.getPortletInfo(route.getSource()).getName() + "</h4>\n" +
+ " <div>Event: " + route.getName().getLocalPart() + "</div>\n" +
+ " </div>\n");
writer.print("<div class=\"event-body\">" +
"<p><label>Source: </label>" + context.getPortletInfo(route.getSource()).getName() + "<img src=\"/simple-portal/images/debug/arrow.gif\" alt=\"\"/>");
@@ -106,7 +106,7 @@
for (EventRoute child : route.getChildren())
{
- id = rand(1, 1000);
+ id = rand(1,1000);
writer.println("<div class=\"children\">");
printRoute(child, writer, context, id, "a");
writer.println("</div>");
@@ -203,7 +203,7 @@
private void formatMap(Map<String, String[]> map, StringBuilder sb)
{
sb.append("{");
- for (Iterator<Map.Entry<String, String[]>> i = map.entrySet().iterator(); i.hasNext();)
+ for (Iterator<Map.Entry<String, String[]>> i = map.entrySet().iterator();i.hasNext();)
{
Map.Entry<String, String[]> entry = i.next();
@@ -226,15 +226,13 @@
}
public static int rand(int lo, int hi)
- {
- Random rn2 = new Random();
- int n = hi - lo + 1;
- int i = rn2.nextInt() % n;
- if (i < 0)
- {
- i = -i;
- }
- return lo + i;
- }
+ {
+ Random rn2 = new Random();
+ int n = hi - lo + 1;
+ int i = rn2.nextInt() % n;
+ if (i < 0)
+ i = -i;
+ return lo + i;
+ }
}
Modified: modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -22,42 +22,42 @@
******************************************************************************/
package org.jboss.portal.portlet.portal.jsp;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.io.SerializationFilter;
-import org.jboss.portal.common.util.Base64;
+import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.URLFormat;
+import org.jboss.portal.portlet.portal.Constants;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.controller.PortletController;
-import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
-import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
-import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
-import org.jboss.portal.portlet.controller.request.PortletActionRequest;
+import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
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.controller.response.PortletResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
-import org.jboss.portal.portlet.invocation.response.ContentResponse;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
-import org.jboss.portal.portlet.portal.Constants;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.web.WebRequest;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletContext;
import java.io.IOException;
import java.io.Writer;
@@ -228,10 +228,9 @@
ErrorResponse errorResponse = (ErrorResponse)pir;
//
- Throwable cause = errorResponse.getCause();
- if (cause != null)
+ if (errorResponse.getCause() != null)
{
- throw new ServletException(Constants.PORTLET_ERROR, cause);
+ throw new ServletException(Constants.PORTLET_ERROR, errorResponse.getCause());
}
else
{
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-04-11 07:23:55 UTC (rev 10533)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/tck/TCKPageNavigationalState.java 2008-04-11 13:43:57 UTC (rev 10534)
@@ -27,7 +27,9 @@
import org.jboss.portal.common.util.ParameterMap;
import javax.xml.namespace.QName;
+import java.util.Map;
import java.util.Set;
+import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
@@ -78,6 +80,11 @@
return defaultState.getPublicNames();
}
+ public void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws IllegalArgumentException, IllegalStateException
+ {
+ defaultState.setPublicNavigationalState(windowId, update);
+ }
+
public String[] getPublicNavigationalState(QName name) throws IllegalArgumentException
{
return defaultState.getPublicNavigationalState(name);
18 years
JBoss Portal SVN: r10533 - branches/JBoss_Portal_Branch_2_7/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-11 03:23:55 -0400 (Fri, 11 Apr 2008)
New Revision: 10533
Modified:
branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml
Log:
oups
Modified: branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml 2008-04-11 00:35:17 UTC (rev 10532)
+++ branches/JBoss_Portal_Branch_2_7/build/build-thirdparty.xml 2008-04-11 07:23:55 UTC (rev 10533)
@@ -76,7 +76,8 @@
<componentref name="dom4j" version="1.6.1jboss"/>
<componentref name="ehcache" version="1.2.2"/>
<componentref name="el" version="1.0"/>
- <componentref name="facelets" version="1.1.1-patched-jboss4.2"/>
+ <componentref name="facelets" version="1.1.14"/>
+ <componentref name="richfaces" version="3.1.4.SR1"/>
<componentref name="hibernate" version="3.2.0.CR2"/>
<componentref name="httpunit" version="1.6"/>
<componentref name="hsqldb" version="1.8.0.2"/>
18 years
JBoss Portal SVN: r10532 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-10 20:35:17 -0400 (Thu, 10 Apr 2008)
New Revision: 10532
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
Log:
- Started integrating new PC controller. Probably broke everything but needed to commit now for synchronization purposes.
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 00:35:04 UTC (rev 10531)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2008-04-11 00:35:17 UTC (rev 10532)
@@ -22,38 +22,72 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.action;
-import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.core.controller.ControllerCommand;
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.command.response.RedirectionResponse;
import org.jboss.portal.core.controller.portlet.ControllerResponseFactory;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.identity.User;
+import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.URLFormat;
+import org.jboss.portal.portlet.controller.PortletController;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.impl.AbstractPortletControllerContext;
+import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
+import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
+import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
+import org.jboss.portal.portlet.controller.request.ControllerRequest;
+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.response.ResourceResponse;
+import org.jboss.portal.portlet.controller.state.AbstractPageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.web.WebRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
public class InvokePortletWindowActionCommand extends InvokeWindowCommand
{
-
/** . */
- private static final Logger log = Logger.getLogger(InvokePortletWindowActionCommand.class);
-
- /** . */
private static final CommandInfo info = new ActionCommandInfo(false);
/** . */
@@ -118,13 +152,8 @@
public void acquireResources() throws NoSuchResourceException
{
super.acquireResources();
+ instance = getInstance(window);
- // We need the user id
- User user = getControllerContext().getUser();
-
- // Get instance
- instance = context.getController().getCustomizationManager().getInstance(window, user);
-
// No instance means we can't continue
if (instance == null)
{
@@ -142,43 +171,322 @@
}
}
+ private Instance getInstance(Window window)
+ {
+ // We need the user id
+ User user = getControllerContext().getUser();
+
+ // Get instance
+ return context.getController().getCustomizationManager().getInstance(window, user);
+ }
+
public ControllerResponse execute() throws ControllerException
{
try
{
- Mode mode = this.mode;
- if (mode == null)
+ // State controller context
+ NavigationalStateContext nsContext = (NavigationalStateContext)context.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ ActionStateControllerContext stateControllerContext = new ActionStateControllerContext(nsContext);
+
+ // Portlet controller context
+ PortletControllerContext controllerContext;
+ HttpServletRequest clientRequest = context.getServerInvocation().getServerContext().getClientRequest();
+ HttpServletResponse clientResponse = context.getServerInvocation().getServerContext().getClientResponse();
+ try
{
- mode = Mode.VIEW;
+ controllerContext = new ActionPortletControllerContext(clientRequest, clientResponse, stateControllerContext);
}
-
- //
- WindowState windowState = this.windowState;
- if (windowState == null)
+ catch (IOException e)
{
- windowState = WindowState.NORMAL;
+ throw new ControllerException("Couldn't create PortletControllerContext!", e);
}
- //
- PortletInvocation invocation = PortletInvocationFactory.createAction(
- context,
- mode,
- windowState,
- navigationalState,
- interactionState,
- formParameters,
- window,
- portal);
+ // The type of invocation
+ String type = (String)clientRequest.getAttribute(URLParameterConstants.TYPE);
- //
- PortletInvocationResponse response = instance.invoke(invocation);
+ // Process only portlet type
+ // The request decoded if not null
+ PageNavigationalState pageNavigationalState = null;
+ if (URLParameterConstants.PORTLET_TYPE.equals(type))
+ {
+ WebRequest wr;
+ try
+ {
+ wr = new WebRequest(clientRequest);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new ControllerException("Couldn't create web request!", e);
+ }
- //
- return ControllerResponseFactory.createActionResponse(targetId, response);
+ PageNavigationalStateSerialization stateSerialization = new PageNavigationalStateSerialization(stateControllerContext);
+ ControllerRequestFactory factory = new ControllerRequestFactory(stateSerialization);
+ ControllerRequest request = factory.createRequest(wr);
+
+ org.jboss.portal.portlet.controller.response.ControllerResponse controllerResponse;
+ controllerResponse = new PortletController().process(controllerContext, request);
+
+ //
+ if (controllerResponse instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
+
+ //
+ pageNavigationalState = pageUpdate.getPageNavigationalState();
+
+ // We perform a send redirect on actions
+ if (request instanceof PortletActionRequest)
+ {
+ PortletURLRenderer renderer = new PortletURLRenderer(pageUpdate.getPageNavigationalState(),
+ clientRequest, clientResponse, stateSerialization);
+
+ //
+ String url = renderer.renderURL(new URLFormat(null, null, true, null));
+ return new RedirectionResponse(url);
+ }
+ }
+ else if (controllerResponse instanceof ResourceResponse)
+ {
+ // todo: deal with this later
+
+ throw new NotYetImplemented("Resources are not currently supported!");
+
+ /* ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
+ PortletInvocationResponse pir = resourceResponse.getResponse();
+
+ //
+ if (pir instanceof ContentResponse)
+ {
+ ContentResponse contentResponse = (ContentResponse)pir;
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_EMPTY)
+ {
+ clientResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = contentResponse.getContentType();
+ if (contentType != null)
+ {
+ clientResponse.setContentType(contentType);
+ }
+
+ //
+ if (contentResponse.getType() == ContentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = clientResponse.getOutputStream();
+ out.write(contentResponse.getBytes());
+ }
+ catch (IOException e)
+ {
+ throw new ControllerException("Couldn't output bytes!", e);
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = clientResponse.getWriter();
+ writer.write(contentResponse.getChars());
+ }
+ catch (IOException e)
+ {
+ throw new ControllerException("Couldn't output chars!", e);
+ }
+ finally
+ {
+ IOTools.safeClose(writer);
+ }
+ }
+ }
+ }
+ else
+ {
+ // todo
+ }*/
+ }
+ else if (controllerResponse instanceof PortletResponse)
+ {
+ PortletResponse portletResponse = (PortletResponse)controllerResponse;
+
+ // Let core deal with the response
+ return ControllerResponseFactory.createActionResponse(targetId, portletResponse.getResponse());
+
+ }
+ else
+ {
+ throw new PortletInvokerException("Unexpected response type: " + controllerResponse.getClass().getName());
+ }
+ }
+ else
+ {
+ PageNavigationalStateSerialization serialization = new PageNavigationalStateSerialization(controllerContext.getStateControllerContext());
+ // The nav state provided with the request
+ // Unmarshall portal navigational state if it is provided
+ pageNavigationalState = null;
+ String blah = clientRequest.getParameter(ControllerRequestParameterNames.PAGE_NAVIGATIONAL_STATE);
+ if (blah != null)
+ {
+ byte[] bytes = Base64.decode(blah, true);
+ pageNavigationalState = IOTools.unserialize(serialization, SerializationFilter.COMPRESSOR, bytes);
+ }
+ }
}
catch (PortletInvokerException e)
{
return ControllerResponseFactory.createResponse(e);
}
+
+ return new UpdateWindowResponse(targetId);
}
+
+ private class ActionPortletControllerContext extends AbstractPortletControllerContext
+ {
+ private final StateControllerContext stateControllerContext;
+
+ public ActionPortletControllerContext(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, ActionStateControllerContext stateControllerContext)
+ throws IllegalRequestException, IOException
+ {
+ super(httpServletRequest, httpServletResponse);
+ stateControllerContext.setPortletControllerContext(this);
+ this.stateControllerContext = stateControllerContext;
+ }
+
+ protected Portlet getPortlet(String windowId) throws PortletInvokerException
+ {
+ PortalObjectId id = PortalObjectId.parse(windowId, PortalObjectPath.CANONICAL_FORMAT);
+ PortalObject portalObject = context.getController().getPortalObjectContainer().getObject(id);
+ if (portalObject instanceof Window)
+ {
+ Window window = (Window)portalObject;
+ Instance instance = getInstance(window);
+ if (instance != null)
+ {
+ return instance.getPortlet();
+ }
+ }
+
+ return null;
+ }
+
+ protected PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws PortletInvokerException
+ {
+ return instance.invoke(portletInvocation);
+ }
+
+ protected Serialization<PageNavigationalState> getPageNavigationalStateSerialization()
+ {
+ return new PageNavigationalStateSerialization(stateControllerContext);
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return null;
+ }
+
+ public StateControllerContext getStateControllerContext()
+ {
+ return stateControllerContext;
+ }
+ }
+
+ private static class ActionPageNavigationalState extends AbstractPageNavigationalState
+ {
+ private ActionStateControllerContext controllerContext;
+
+ private ActionPageNavigationalState(ActionStateControllerContext controllerContext, boolean modifiable)
+ {
+ super(modifiable);
+ this.controllerContext = controllerContext;
+ }
+
+ private NavigationalStateContext getNSContext()
+ {
+ return controllerContext.nsContext;
+ }
+
+ private PortletControllerContext getPCContext()
+ {
+ return controllerContext.controllerContext;
+ }
+
+ public Set<String> getWindowIds()
+ {
+ return getNSContext().getKeys();
+ }
+
+ public WindowNavigationalState getWindowNavigationalState(String windowId) throws IllegalArgumentException
+ {
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState coreNS = getNSContext().getWindowNavigationalState(windowId);
+
+ if (coreNS != null)
+ {
+ return new WindowNavigationalState(coreNS.getContentState(), coreNS.getMode(), coreNS.getWindowState());
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState windowNS) throws IllegalArgumentException, IllegalStateException
+ {
+ if (windowNS != null)
+ {
+ org.jboss.portal.core.model.portal.navstate.WindowNavigationalState coreNS =
+ new org.jboss.portal.core.model.portal.navstate.WindowNavigationalState(windowNS.getWindowState(),
+ windowNS.getMode(), windowNS.getPortletNavigationalState());
+ getNSContext().setWindowNavigationalState(windowId, coreNS);
+ }
+ else
+ {
+ getNSContext().setWindowNavigationalState(windowId, null);
+ }
+ }
+
+ protected PortletInfo getPortletInfo(String windowId)
+ {
+ return getPCContext().getPortletInfo(windowId);
+ }
+ }
+
+ private static class ActionStateControllerContext implements StateControllerContext
+ {
+ private PortletControllerContext controllerContext;
+ private NavigationalStateContext nsContext;
+
+ public ActionStateControllerContext(NavigationalStateContext nsContext)
+ {
+ this.nsContext = nsContext;
+ }
+
+ public PageNavigationalState clonePageNavigationalState(PageNavigationalState pageNavigationalState, boolean modifiable)
+ {
+ if (pageNavigationalState != null)
+ {
+ return new ActionPageNavigationalState(this, modifiable);
+ }
+ return null;
+ }
+
+ public PageNavigationalState createPageNavigationalState(boolean modifiable)
+ {
+ return new ActionPageNavigationalState(this, modifiable);
+ }
+
+ public void setPortletControllerContext(PortletControllerContext portletControllerContext)
+ {
+ this.controllerContext = portletControllerContext;
+ }
+ }
}
18 years
JBoss Portal SVN: r10531 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: model/portal/command/render and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-10 20:35:04 -0400 (Thu, 10 Apr 2008)
New Revision: 10531
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
Log:
- Minor improvements.
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java 2008-04-11 00:31:22 UTC (rev 10530)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java 2008-04-11 00:35:04 UTC (rev 10531)
@@ -22,10 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.controller.command.mapper;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.server.ServerInvocation;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -33,9 +30,4 @@
*/
public abstract class AbstractCommandFactory extends AbstractJBossService implements CommandFactory
{
-
- public abstract ControllerCommand doMapping(
- ControllerContext controllerContext, ServerInvocation invocation,
- String host, String contextPath,
- String requestPath);
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java 2008-04-11 00:31:22 UTC (rev 10530)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java 2008-04-11 00:35:04 UTC (rev 10531)
@@ -49,7 +49,7 @@
{
if (parameterMap.get("location") != null)
{
- location = URLDecoder.decode(((String[])parameterMap.get("location"))[0], "UTF-8");
+ location = URLDecoder.decode(parameterMap.get("location")[0], "UTF-8");
}
}
catch (UnsupportedEncodingException e)
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-11 00:31:22 UTC (rev 10530)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2008-04-11 00:35:04 UTC (rev 10531)
@@ -56,7 +56,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
/**
* Render a full page.
@@ -71,7 +70,7 @@
private static final CommandInfo info = new ViewCommandInfo();
/** The windows to render. */
- private Collection windows;
+ private Collection<PortalObject> windows;
/** . */
private boolean personalizable;
@@ -106,7 +105,7 @@
super.acquireResources();
// All windows on the page
- windows = new ArrayList(getPage().getChildren(PortalObject.WINDOW_MASK));
+ windows = new ArrayList<PortalObject>(getPage().getChildren(PortalObject.WINDOW_MASK));
}
protected Page initPage()
@@ -186,12 +185,11 @@
WindowContextFactory wcFactory = new WindowContextFactory(context);
// Render the windows
- for (Iterator i = windows.iterator(); i.hasNext();)
+ for (PortalObject po : windows)
{
- PortalObject o = (PortalObject)i.next();
- if (o instanceof Window)
+ if (po instanceof Window)
{
- Window window = (Window)o;
+ Window window = (Window)po;
RenderWindowCommand renderCmd = new RenderWindowCommand(window.getId());
//
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-11 00:31:22 UTC (rev 10530)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2008-04-11 00:35:04 UTC (rev 10531)
@@ -22,23 +22,23 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.render;
+import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.control.page.PageControlContext;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.navstate.NavigationalStateKey;
-import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.invocation.RenderInvocation;
@@ -55,8 +55,7 @@
/** . */
private WindowRendition rendition;
- public RenderWindowCommand(PortalObjectId windowId)
- throws IllegalArgumentException
+ public RenderWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
{
super(windowId);
}
18 years
JBoss Portal SVN: r10530 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: controller/ajax and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-10 20:31:22 -0400 (Thu, 10 Apr 2008)
New Revision: 10530
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/navstate/NavigationalStateContext.java
Log:
- Moved methods from PortalObjectNavigationalStateContext to NavigationalStateContext.
- Implemented PortalObjectNavigationalStateContext.getKeys.
- Use NavigationalStateContext instead of implementation.
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2008-04-11 00:20:29 UTC (rev 10529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2008-04-11 00:31:22 UTC (rev 10530)
@@ -27,7 +27,7 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.model.portal.navstate.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
/**
* Apply navigational state changes.
@@ -45,7 +45,7 @@
ControllerContext controllerContext = cmd.getControllerContext();
if (controllerContext.getDepth() == 1 && controllerContext.getType() == ControllerContext.CLASSIC_TYPE)
{
- PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ NavigationalStateContext ctx = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
ctx.applyChanges();
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2008-04-11 00:20:29 UTC (rev 10529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2008-04-11 00:31:22 UTC (rev 10530)
@@ -27,7 +27,7 @@
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.model.portal.navstate.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.server.AbstractServerURL;
import org.jboss.portal.server.ServerInvocationContext;
@@ -44,13 +44,12 @@
*/
public class AjaxInterceptor extends ControllerInterceptor
{
- /**
- * Luca Stancapiano - 29 - 09 -2007
- * targetContextPath is used to assign a context path when
- * default portal-ajax path cannot to be used or if it is changed through context-root property into jboss-web.xml
- * */
+ /**
+ * Luca Stancapiano - 29 - 09 -2007 targetContextPath is used to assign a context path when default portal-ajax path
+ * cannot to be used or if it is changed through context-root property into jboss-web.xml
+ */
private String targetContextPath = "/portal-ajax";
-
+
public ControllerResponse invoke(ControllerCommand cmd) throws Exception, InvocationException
{
ControllerResponse response = (ControllerResponse)cmd.invokeNext();
@@ -68,7 +67,7 @@
Map pageProps = rendition.getPageResult().getProperties();
//
- PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ NavigationalStateContext ctx = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
String viewId = ctx.getViewId();
//
@@ -95,7 +94,7 @@
//
return response;
}
-
+
public String getTargetContextPath()
{
return targetContextPath;
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-11 00:20:29 UTC (rev 10529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2008-04-11 00:31:22 UTC (rev 10530)
@@ -48,9 +48,9 @@
import org.jboss.portal.core.model.portal.command.response.UpdateWindowResponse;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.model.portal.content.WindowRendition;
-import org.jboss.portal.core.model.portal.navstate.PortalObjectNavigationalStateContext;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.navstate.NavigationalStateChange;
+import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
import org.jboss.portal.core.theme.WindowContextFactory;
@@ -185,7 +185,7 @@
Page page = (Page)window.getParent();
//
- PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ NavigationalStateContext ctx = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
// The windows marked dirty during the request
Set dirtyWindowIds = new HashSet();
@@ -253,10 +253,9 @@
//
if (!fullRefresh)
{
- ArrayList refreshedWindows = new ArrayList();
- for (Iterator i = page.getChildren(PortalObject.WINDOW_MASK).iterator(); i.hasNext();)
+ ArrayList<PortalObject> refreshedWindows = new ArrayList<PortalObject>();
+ for (PortalObject child : page.getChildren(PortalObject.WINDOW_MASK))
{
- PortalObject child = (PortalObject)i.next();
PortalObjectId childId = child.getId();
if (dirtyWindowIds.contains(childId))
{
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-11 00:20:29 UTC (rev 10529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-04-11 00:31:22 UTC (rev 10530)
@@ -25,11 +25,13 @@
import org.jboss.logging.Logger;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
-import org.jboss.portal.core.model.portal.PortalObjectId;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Set;
@@ -41,7 +43,7 @@
public class PortalObjectNavigationalStateContext implements NavigationalStateContext
{
/** . */
- private Logger logger = Logger.getLogger(PortalObjectNavigationalStateContext.class);
+ private static final Logger logger = Logger.getLogger(PortalObjectNavigationalStateContext.class);
/** . */
private static final String VIEW_ID_KEY = "view_id";
@@ -50,7 +52,7 @@
private AttributeResolver store;
/** The changes. */
- private LinkedHashMap changes;
+ private LinkedHashMap<NavigationalStateKey, NavigationalStateObjectChange> changes;
public PortalObjectNavigationalStateContext(AttributeResolver store)
{
@@ -59,7 +61,14 @@
public Set getKeys()
{
- throw new UnsupportedOperationException("todo");
+ Set storeKeys = store.getKeys();
+ Set<String> keys = new HashSet<String>(storeKeys.size() + changes.size());
+ keys.addAll(storeKeys);
+ for (NavigationalStateKey key : changes.keySet())
+ {
+ keys.add(key.getId().toString());
+ }
+ return keys;
}
public Object getAttribute(Object attrKey) throws IllegalArgumentException
@@ -69,7 +78,7 @@
// Browse changes first
if (changes != null)
{
- NavigationalStateObjectChange change = (NavigationalStateObjectChange)changes.get(nsKey);
+ NavigationalStateObjectChange change = changes.get(nsKey);
if (change != null)
{
switch (change.getType())
@@ -96,7 +105,7 @@
Class typeClass = wantedKey.getType();
if (typeClass != WindowNavigationalState.class)
{
- throw new IllegalArgumentException("Cannot handle the type " + typeClass.getName());
+ throw new IllegalArgumentException("Can only set WindowNavigationalSate attributes, was given " + typeClass.getName());
}
//
@@ -105,7 +114,7 @@
// Look first the old ns in the changes
if (changes != null)
{
- NavigationalStateObjectChange change = (NavigationalStateObjectChange)changes.get(wantedKey);
+ NavigationalStateObjectChange change = changes.get(wantedKey);
if (change != null)
{
// Discard any change done so far
@@ -161,7 +170,7 @@
{
if (changes == null)
{
- changes = new LinkedHashMap();
+ changes = new LinkedHashMap<NavigationalStateKey, NavigationalStateObjectChange>();
}
//
@@ -169,11 +178,23 @@
}
}
- public Iterator getChanges()
+ public Iterator<NavigationalStateObjectChange> getChanges()
{
return changes.values().iterator();
}
+ public WindowNavigationalState getWindowNavigationalState(String windowId)
+ {
+ NavigationalStateKey key = getKeyFrom(windowId);
+ return (WindowNavigationalState)getAttribute(key);
+ }
+
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState windowNavigationalState)
+ {
+ NavigationalStateKey key = getKeyFrom(windowId);
+ setAttribute(key, windowNavigationalState);
+ }
+
/**
* Apply the navigational state changes to the real storage.
*
@@ -184,9 +205,8 @@
if (changes != null && changes.size() > 0)
{
Object maximizedKey = null;
- for (Iterator i = changes.values().iterator(); i.hasNext();)
+ for (NavigationalStateObjectChange change : changes.values())
{
- NavigationalStateObjectChange change = (NavigationalStateObjectChange)i.next();
if (change.getNewValue() instanceof WindowNavigationalState)
{
WindowNavigationalState wns = (WindowNavigationalState)change.getNewValue();
@@ -210,10 +230,8 @@
if (maximizedKey != null)
{
Set keys = store.getKeys();
- Iterator it = keys.iterator();
- while (it.hasNext())
+ for (Object key : keys)
{
- Object key = it.next();
Object object = store.getAttribute(key);
if (object instanceof WindowNavigationalState)
{
@@ -235,11 +253,11 @@
Integer viewId = (Integer)store.getAttribute(VIEW_ID_KEY);
if (viewId == null)
{
- viewId = new Integer(0);
+ viewId = 0;
}
else
{
- viewId = new Integer(viewId.intValue() + 1);
+ viewId = viewId + 1;
}
store.setAttribute(VIEW_ID_KEY, viewId);
@@ -252,14 +270,14 @@
}
}
- /**
- * Returns the current view id.
- *
- * @return the view id
- */
public String getViewId()
{
Integer viewId = (Integer)store.getAttribute(VIEW_ID_KEY);
return viewId != null ? viewId.toString() : "0";
}
+
+ private NavigationalStateKey getKeyFrom(String windowId)
+ {
+ return new NavigationalStateKey(WindowNavigationalState.class, PortalObjectId.parse(windowId, PortalObjectPath.CANONICAL_FORMAT));
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/navstate/NavigationalStateContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/navstate/NavigationalStateContext.java 2008-04-11 00:20:29 UTC (rev 10529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/navstate/NavigationalStateContext.java 2008-04-11 00:31:22 UTC (rev 10530)
@@ -23,11 +23,53 @@
package org.jboss.portal.core.navstate;
import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import java.util.Iterator;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision$
*/
public interface NavigationalStateContext extends AttributeResolver
{
+ /**
+ * Retrieves the navigational state associated with the specified window identifier.
+ *
+ * @param windowId a String identifying the window which navigational state is to be retrieved
+ * @return the navigational state associated with the specified window identifier or <code>null</code> if the given
+ * window identifier is not known by this NavigationalStateContext or no navigational state is associated
+ * with the given identifier.
+ */
+ WindowNavigationalState getWindowNavigationalState(String windowId);
+
+ /**
+ * Set the navigational state associated with the window identified by the given identifier.
+ *
+ * @param windowId the window identifier
+ * @param windowNavigationalState the window navigational state
+ */
+ void setWindowNavigationalState(String windowId, WindowNavigationalState windowNavigationalState);
+
+ /**
+ * Apply the navigational state changes made to this NavigationalStateContext.
+ *
+ * @return true if state changed
+ */
+ boolean applyChanges();
+
+ /**
+ * Returns the current view id.
+ *
+ * @return the view id
+ */
+ String getViewId();
+
+ /**
+ * Retrieve an iterator over the current changes.
+ *
+ * @return an iterator over the current changes.
+ */
+ Iterator<? extends NavigationalStateChange> getChanges();
}
18 years
JBoss Portal SVN: r10529 - in modules/portlet/trunk: controller/src/main/java/org/jboss/portal/portlet/controller and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-10 20:20:29 -0400 (Thu, 10 Apr 2008)
New Revision: 10529
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java
modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
modules/portlet/trunk/releaseLibs.sh
Log:
- Minor.
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-11 00:20:05 UTC (rev 10528)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/PortletControllerContext.java 2008-04-11 00:20:29 UTC (rev 10529)
@@ -33,10 +33,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -59,13 +56,13 @@
/**
* Create a portlet invocation context for the specified window id.
*
- * @param windowId the window id
+ * @param windowId the window id
* @param pageNavigationalState the page navigational state
* @return a portlet invocation context
*/
PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageNavigationalState);
- PortletInvocationResponse invoke( ActionInvocation actionInvocation) throws PortletInvokerException;
+ PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws PortletInvokerException;
PortletInvocationResponse invoke(List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException;
Modified: modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java
===================================================================
--- modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java 2008-04-11 00:20:05 UTC (rev 10528)
+++ modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/admin/ui/DebuggerPortlet.java 2008-04-11 00:20:29 UTC (rev 10529)
@@ -22,24 +22,24 @@
******************************************************************************/
package org.jboss.portal.portlet.portal.admin.ui;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+import org.jboss.portal.portlet.portal.jsp.EventAcknowledgement;
+import org.jboss.portal.portlet.portal.jsp.EventRoute;
import org.jboss.portal.portlet.portal.jsp.PageEventControllerContext;
-import org.jboss.portal.portlet.portal.jsp.EventRoute;
import org.jboss.portal.portlet.portal.jsp.PagePortletControllerContext;
-import org.jboss.portal.portlet.portal.jsp.EventAcknowledgement;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.ParametersStateString;
import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-import javax.portlet.PortletException;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Random;
-import java.util.Map;
-import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -70,7 +70,7 @@
int id;
for (EventRoute route : eventCC.getRoots())
{
- id = rand(1,1000);
+ id = rand(1, 1000);
writer.println("<div class=\"event\" id=\"event-" + id + "\">\n");
printRoute(route, writer, context, id, "");
writer.println("</div>\n");
@@ -83,13 +83,13 @@
}
}
- private void printRoute(EventRoute route, PrintWriter writer,PagePortletControllerContext context, int id, String cid)
+ private void printRoute(EventRoute route, PrintWriter writer, PagePortletControllerContext context, int id, String cid)
{
writer.print("<div onmouseover=\"showDetails(this,'details-" + id + cid + "')\" onmouseout=\"hideDetails(this,'details-" + id + cid + "')\" onclick=\"new Effect.Highlight('" + context.getPortletInfo(route.getSource()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'start', scope: 'highlight', limit:2}});new Effect.Highlight('" + context.getPortletInfo(route.getDestination()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'end', scope: 'highlight', limit:2}});\" >" +
"<div class=\"event-header\">\n" +
- " <h4>" + context.getPortletInfo(route.getSource()).getName() + "</h4>\n" +
- " <div>Event: " + route.getName().getLocalPart() + "</div>\n" +
- " </div>\n");
+ " <h4>" + context.getPortletInfo(route.getSource()).getName() + "</h4>\n" +
+ " <div>Event: " + route.getName().getLocalPart() + "</div>\n" +
+ " </div>\n");
writer.print("<div class=\"event-body\">" +
"<p><label>Source: </label>" + context.getPortletInfo(route.getSource()).getName() + "<img src=\"/simple-portal/images/debug/arrow.gif\" alt=\"\"/>");
@@ -106,7 +106,7 @@
for (EventRoute child : route.getChildren())
{
- id = rand(1,1000);
+ id = rand(1, 1000);
writer.println("<div class=\"children\">");
printRoute(child, writer, context, id, "a");
writer.println("</div>");
@@ -203,7 +203,7 @@
private void formatMap(Map<String, String[]> map, StringBuilder sb)
{
sb.append("{");
- for (Iterator<Map.Entry<String, String[]>> i = map.entrySet().iterator();i.hasNext();)
+ for (Iterator<Map.Entry<String, String[]>> i = map.entrySet().iterator(); i.hasNext();)
{
Map.Entry<String, String[]> entry = i.next();
@@ -226,13 +226,15 @@
}
public static int rand(int lo, int hi)
- {
- Random rn2 = new Random();
- int n = hi - lo + 1;
- int i = rn2.nextInt() % n;
- if (i < 0)
- i = -i;
- return lo + i;
- }
+ {
+ Random rn2 = new Random();
+ int n = hi - lo + 1;
+ int i = rn2.nextInt() % n;
+ if (i < 0)
+ {
+ i = -i;
+ }
+ return lo + i;
+ }
}
Modified: modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2008-04-11 00:20:05 UTC (rev 10528)
+++ modules/portlet/trunk/portal/src/main/java/org/jboss/portal/portlet/portal/jsp/ControllerFilter.java 2008-04-11 00:20:29 UTC (rev 10529)
@@ -22,42 +22,42 @@
******************************************************************************/
package org.jboss.portal.portlet.portal.jsp;
-import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
-import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.URLFormat;
-import org.jboss.portal.portlet.portal.Constants;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.ContentResponse;
-import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.controller.PortletController;
-import org.jboss.portal.portlet.controller.request.PortletActionRequest;
+import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
+import org.jboss.portal.portlet.controller.impl.URLParameterConstants;
import org.jboss.portal.portlet.controller.impl.request.ControllerRequestFactory;
+import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
-import org.jboss.portal.portlet.controller.impl.request.ControllerRequestParameterNames;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
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.controller.response.PortletResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.PageNavigationalStateSerialization;
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.io.SerializationFilter;
-import org.jboss.portal.common.util.Base64;
+import org.jboss.portal.portlet.invocation.response.ContentResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.portlet.portal.Constants;
import org.jboss.portal.web.WebRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
-import javax.servlet.Filter;
-import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;
@@ -228,9 +228,10 @@
ErrorResponse errorResponse = (ErrorResponse)pir;
//
- if (errorResponse.getCause() != null)
+ Throwable cause = errorResponse.getCause();
+ if (cause != null)
{
- throw new ServletException(Constants.PORTLET_ERROR, errorResponse.getCause());
+ throw new ServletException(Constants.PORTLET_ERROR, cause);
}
else
{
Modified: modules/portlet/trunk/releaseLibs.sh
===================================================================
--- modules/portlet/trunk/releaseLibs.sh 2008-04-11 00:20:05 UTC (rev 10528)
+++ modules/portlet/trunk/releaseLibs.sh 2008-04-11 00:20:29 UTC (rev 10529)
@@ -1,4 +1,4 @@
-repos=$HOME/Dev/portal-modules-respo/portlet/trunk-SNAPSHOT/lib
+repos=$HOME/Dev/portal-modules-repos/portlet/trunk-SNAPSHOT/lib
thirdparty=$HOME/Dev/jboss-portal-2.7/thirdparty/jboss-portal/modules/portlet/lib
echo "Copies current version of portlet libraries either to local repository copy or Portal thirdparty to test or release purpose"
18 years
JBoss Portal SVN: r10528 - in modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller: state and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-10 20:20:05 -0400 (Thu, 10 Apr 2008)
New Revision: 10528
Added:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
Log:
- Added AbstractPageNavigationalState to make PageNavigationalState implementations easier.
Modified: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-10 23:32:30 UTC (rev 10527)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-04-11 00:20:05 UTC (rev 10528)
@@ -22,13 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.controller.impl.state;
-import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.AbstractPageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
-import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -38,35 +35,26 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PageNavigationalStateImpl implements PageNavigationalState, Serializable
+public class PageNavigationalStateImpl extends AbstractPageNavigationalState implements Serializable
{
-
/** . */
protected final StateControllerContextImpl context;
/** . */
protected final Map<String, WindowNavigationalState> windows;
- /** . */
- protected final Map<QName, String[]> page;
-
- /** . */
- private final boolean modifiable;
-
protected PageNavigationalStateImpl(StateControllerContextImpl context, boolean modifiable)
{
+ super(modifiable);
this.context = context;
this.windows = new HashMap<String, WindowNavigationalState>();
- this.page = new HashMap<QName, String[]>();
- this.modifiable = modifiable;
}
public PageNavigationalStateImpl(PageNavigationalStateImpl original, boolean modifiable)
{
+ super(modifiable, original.page);
this.context = original.context;
this.windows = new HashMap<String, WindowNavigationalState>(original.windows);
- this.page = new HashMap<QName, String[]>(original.page);
- this.modifiable = modifiable;
}
public Set<String> getWindowIds()
@@ -79,47 +67,6 @@
return windows.get(windowId);
}
- public ParameterMap getPublicNavigationalState(String windowId)
- {
- PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
-
- //
- if (info != null)
- {
- ParameterMap publicNavigationalState = new ParameterMap();
- for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
- {
- String[] parameterValue = page.get(parameterInfo.getName());
-
- //
- if (parameterValue != null)
- {
- String parameterId = parameterInfo.getId();
-
- // We clone the value here so we keep the internal state not potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
- }
- }
-
- //
- return publicNavigationalState;
- }
-
- //
- return null;
- }
-
- public Set<QName> getPublicNames()
- {
- return page.keySet();
- }
-
- public String[] getPublicNavigationalState(QName name)
- {
- String[] values = page.get(name);
- return values != null ? values.clone() : null;
- }
-
public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState)
{
if (!modifiable)
@@ -131,25 +78,8 @@
windows.put(windowId, windowState);
}
- public void setPublicNavigationalState(QName name, String[] value)
+ protected PortletInfo getPortletInfo(String windowId)
{
- if (!modifiable)
- {
- throw new IllegalStateException("The page navigational state is not modifiable");
- }
-
- // We clone the value in order to keep the state not mutated by a side effect
- page.put(name, value.clone());
+ return context.portletControllerContext.getPortletInfo(windowId);
}
-
- public void removePublicNavigationalState(QName name)
- {
- if (!modifiable)
- {
- throw new IllegalStateException("The page navigational state is not modifiable");
- }
-
- //
- page.remove(name);
- }
}
\ No newline at end of file
Added: modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java
===================================================================
--- modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java (rev 0)
+++ modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/state/AbstractPageNavigationalState.java 2008-04-11 00:20:05 UTC (rev 10528)
@@ -0,0 +1,120 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.portal.portlet.controller.state;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.info.ParameterInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPageNavigationalState implements PageNavigationalState
+{
+ /** . */
+ protected final Map<QName, String[]> page;
+ /** . */
+ protected final boolean modifiable;
+
+ protected AbstractPageNavigationalState(boolean modifiable)
+ {
+ this(modifiable, new HashMap<QName, String[]>());
+ }
+
+ protected AbstractPageNavigationalState(boolean modifiable, Map<QName, String[]> page)
+ {
+ this.modifiable = modifiable;
+ this.page = page;
+ }
+
+ public ParameterMap getPublicNavigationalState(String windowId)
+ {
+ PortletInfo info = getPortletInfo(windowId);
+
+ //
+ if (info != null)
+ {
+ ParameterMap publicNavigationalState = new ParameterMap();
+ for (ParameterInfo parameterInfo : info.getNavigation().getPublicParameters())
+ {
+ String[] parameterValue = page.get(parameterInfo.getName());
+
+ //
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
+ }
+
+ //
+ return publicNavigationalState;
+ }
+
+ //
+ return null;
+ }
+
+ protected abstract PortletInfo getPortletInfo(String windowId);
+
+ public Set<QName> getPublicNames()
+ {
+ return page.keySet();
+ }
+
+ public String[] getPublicNavigationalState(QName name)
+ {
+ String[] values = page.get(name);
+ return values != null ? values.clone() : null;
+ }
+
+ public void setPublicNavigationalState(QName name, String[] value)
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ // We clone the value in order to keep the state not mutated by a side effect
+ page.put(name, value.clone());
+ }
+
+ public void removePublicNavigationalState(QName name)
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ page.remove(name);
+ }
+}
18 years