Author: julien(a)jboss.com
Date: 2008-04-28 07:29:14 -0400 (Mon, 28 Apr 2008)
New Revision: 10726
Added:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationEventControllerContext.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletControllerContext.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletPageNavigationalState.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationStateControllerContext.java
Modified:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/PortletPresentationServer.java
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/spi/PresentationPortletInvocationContext.java
Log:
rename portlet controller integration classes with PF
Modified:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/PortletPresentationServer.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/PortletPresentationServer.java 2008-04-28
11:26:46 UTC (rev 10725)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/PortletPresentationServer.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -34,8 +34,8 @@
import org.jboss.portal.presentation.model.tree.UINode;
import org.jboss.portal.presentation.client.PresentationClient;
import org.jboss.portal.presentation.portlet.protocol.PortletContainerAction;
-import
org.jboss.portal.presentation.portlet.controller.StructuralPortletPageNavigationalState;
-import
org.jboss.portal.presentation.portlet.controller.StructuralPortletControllerContext;
+import
org.jboss.portal.presentation.portlet.controller.PresentationPortletPageNavigationalState;
+import
org.jboss.portal.presentation.portlet.controller.PresentationPortletControllerContext;
import org.jboss.portal.presentation.impl.model.tree.UINodeFactory;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
import org.jboss.portal.portlet.controller.request.PortletActionRequest;
@@ -89,16 +89,16 @@
PortletController controller = new PortletController();
//
- StructuralPortletControllerContext portletControllerContext = new
StructuralPortletControllerContext(
+ PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
client,
pageNode,
portletInvoker);
//
- StructuralPortletPageNavigationalState pageNavigationalState = new
StructuralPortletPageNavigationalState(
+ PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
portletControllerContext,
client.getNavigationalStateContext(),
- StructuralPortletPageNavigationalState.READ_ONLY_MODE);
+ PresentationPortletPageNavigationalState.READ_ONLY_MODE);
PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, windowId);
@@ -136,15 +136,15 @@
UINode pageNode = windowNode.getParent();
//
- StructuralPortletControllerContext portletControllerContext = new
StructuralPortletControllerContext(
+ PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
client,
pageNode,
portletInvoker);
- StructuralPortletPageNavigationalState pageNavigationalState = new
StructuralPortletPageNavigationalState(
+ PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
portletControllerContext,
client.getNavigationalStateContext(),
- StructuralPortletPageNavigationalState.CLONE_AND_WRITE_MODE);
+ PresentationPortletPageNavigationalState.CLONE_AND_WRITE_MODE);
//
ControllerRequest controllerRequest;
@@ -192,7 +192,7 @@
NavigationalStateContext nsc = client.getNavigationalStateContext();
//
- StructuralPortletPageNavigationalState blah =
(StructuralPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
+ PresentationPortletPageNavigationalState blah =
(PresentationPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
//
blah.flush();
Copied:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationEventControllerContext.java
(from rev 10724,
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralEventControllerContext.java)
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationEventControllerContext.java
(rev 0)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationEventControllerContext.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.presentation.portlet.controller;
+
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.event.EventPhaseContext;
+import org.jboss.portal.portlet.controller.event.PortletWindowEvent;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationEventControllerContext implements EventControllerContext
+{
+
+ /** . */
+ private final PresentationPortletControllerContext portletControllerContext;
+
+ public PresentationEventControllerContext(PresentationPortletControllerContext
portletControllerContext)
+ {
+ this.portletControllerContext = portletControllerContext;
+ }
+
+ public void eventProduced(EventPhaseContext context, PortletWindowEvent producedEvent,
PortletWindowEvent sourceEvent)
+ {
+ for (String windowId : portletControllerContext.getWindowIds())
+ {
+ PortletInfo portletInfo = portletControllerContext.getPortletInfo(windowId);
+ if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
+ {
+ PortletWindowEvent distributedEvent = new
PortletWindowEvent(producedEvent.getName(), producedEvent.getPayload(), windowId);
+ context.queueEvent(distributedEvent);
+ }
+ }
+ }
+
+ public void eventConsumed(EventPhaseContext context, PortletWindowEvent consumedEvent,
PortletInvocationResponse consumerResponse)
+ {
+ }
+
+ public void eventFailed(EventPhaseContext context, PortletWindowEvent failedEvent,
Throwable throwable)
+ {
+ }
+
+ public void eventDiscarded(EventPhaseContext context, PortletWindowEvent
discardedEvent, int cause)
+ {
+ }
+}
Copied:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletControllerContext.java
(from rev 10724,
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletControllerContext.java)
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletControllerContext.java
(rev 0)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletControllerContext.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -0,0 +1,208 @@
+/******************************************************************************
+ * 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.presentation.portlet.controller;
+
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
+import org.jboss.portal.portlet.info.PortletInfo;
+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.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationPortletInvocationContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationServerContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationWindowContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationInstanceContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationClientContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationPortalContext;
+import org.jboss.portal.presentation.portlet.spi.PresentationSecurityContext;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.model.tree.UINode;
+import org.jboss.portal.presentation.model.ui.UIObject;
+import org.jboss.portal.presentation.model.ui.UIWindow;
+import org.jboss.portal.presentation.state.StateType;
+
+import javax.servlet.http.Cookie;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationPortletControllerContext implements PortletControllerContext
+{
+
+ /** . */
+ private final UINode pageNode;
+
+ /** . */
+ private final PortletInvoker invoker;
+
+ /** . */
+ private final StateControllerContext stateControllerContext;
+
+ /** A map of window ids to portlets. */
+ private final Map<String, Portlet> portlets;
+
+ /** A map of window ids to windows. */
+ private final Map<String, UINode> windows;
+
+ /** . */
+ private final PresentationClient client;
+
+ /** . */
+ private final EventControllerContext eventControllerContext;
+
+ public PresentationPortletControllerContext(
+ PresentationClient client,
+ UINode pageNode,
+ PortletInvoker invoker)
+ {
+ Map<String, Portlet> portlets = new HashMap<String, Portlet>();
+ Map<String, UINode> windows = new HashMap<String, UINode>();
+
+ //
+ for (UINode childNode : pageNode.getChildren())
+ {
+ UIObject child = childNode.getObject();
+
+ if (child instanceof UIWindow)
+ {
+ String portletRef = child.getProperty(StateType.STRUCTURAL,
"portlet-ref", String.class);
+
+ //
+ if (portletRef != null)
+ {
+ try
+ {
+ Portlet portlet =
invoker.getPortlet(PortletContext.createPortletContext(portletRef));
+
+ //
+ portlets.put(child.getId(), portlet);
+ windows.put(child.getId(), childNode);
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ //
+ this.client = client;
+ this.pageNode = pageNode;
+ this.invoker = invoker;
+ this.stateControllerContext = new PresentationStateControllerContext(this);
+ this.portlets = portlets;
+ this.windows = windows;
+ this.eventControllerContext = new PresentationEventControllerContext(this);
+ }
+
+ public String getPageId()
+ {
+ return pageNode.getObject().getId();
+ }
+
+ public Set<String> getWindowIds()
+ {
+ return windows.keySet();
+ }
+
+ public PortletInfo getPortletInfo(String windowId)
+ {
+ return portlets.get(windowId).getInfo();
+ }
+
+ public PortletInvocationContext createPortletInvocationContext(String windowId,
PortletPageNavigationalState pageNavigationalState)
+ {
+ return new PresentationPortletInvocationContext(client, this, windowId);
+ }
+
+ public PortletInvocationResponse invoke(ActionInvocation actionInvocation) throws
PortletInvokerException
+ {
+ return invoke((PortletInvocation)actionInvocation);
+ }
+
+ public PortletInvocationResponse invoke(List<Cookie> requestCookies,
EventInvocation eventInvocation) throws PortletInvokerException
+ {
+ return invoke(eventInvocation);
+ }
+
+ public PortletInvocationResponse invoke(List<Cookie> requestCookies,
RenderInvocation renderInvocation) throws PortletInvokerException
+ {
+ return invoke(renderInvocation);
+ }
+
+ public PortletInvocationResponse invoke(ResourceInvocation resourceInvocation) throws
PortletInvokerException
+ {
+ return invoke((PortletInvocation)resourceInvocation);
+ }
+
+ private PortletInvocationResponse invoke(PortletInvocation portletInvocation) throws
PortletInvokerException
+ {
+ PresentationPortletInvocationContext ctx =
(PresentationPortletInvocationContext)portletInvocation.getContext();
+
+ //
+ UINode window = windows.get(ctx.getWindowId());
+
+ //
+ portletInvocation.setServerContext(new PresentationServerContext(client));
+ portletInvocation.setSecurityContext(new PresentationSecurityContext());
+ portletInvocation.setClientContext(new PresentationClientContext());
+ portletInvocation.setInstanceContext(new PresentationInstanceContext(window));
+ portletInvocation.setPortalContext(new PresentationPortalContext());
+ portletInvocation.setUserContext(new AbstractUserContext());
+ portletInvocation.setWindowContext(new PresentationWindowContext(window));
+
+ //
+ Portlet portlet = portlets.get(ctx.getWindowId());
+ portletInvocation.setTarget(portlet.getContext());
+
+ //
+ return invoker.invoke(portletInvocation);
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
+
+ public StateControllerContext getStateControllerContext()
+ {
+ return stateControllerContext;
+ }
+}
Copied:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletPageNavigationalState.java
(from rev 10724,
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralPortletPageNavigationalState.java)
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletPageNavigationalState.java
(rev 0)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationPortletPageNavigationalState.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -0,0 +1,290 @@
+/******************************************************************************
+ * 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.presentation.portlet.controller;
+
+import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
+import org.jboss.portal.portlet.controller.state.PortletWindowNavigationalState;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.info.ParameterInfo;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import
org.jboss.portal.presentation.impl.state.navigational.DelegatingNavigationalStateContext;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.xml.namespace.QName;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationPortletPageNavigationalState implements
PortletPageNavigationalState
+{
+
+ /** . */
+ public static final int READ_ONLY_MODE = 0;
+
+ /** . */
+ public static final int READ_WRITE_MODE = 1;
+
+ /** . */
+ public static final int CLONE_AND_WRITE_MODE = 2;
+
+ /** . */
+ private final PresentationPortletControllerContext portletControllerContext;
+
+ /** . */
+ private final NavigationalStateContext navigationalStateContext;
+
+ /** . */
+ private final boolean modifiable;
+
+ public PresentationPortletPageNavigationalState(
+ PresentationPortletControllerContext portletControllerContext,
+ NavigationalStateContext navigationalStateContext,
+ int mode)
+ {
+ boolean modifiable;
+ switch (mode)
+ {
+ case READ_ONLY_MODE:
+ modifiable = false;
+ break;
+ case READ_WRITE_MODE:
+ modifiable = true;
+ break;
+ case CLONE_AND_WRITE_MODE:
+ modifiable = true;
+ navigationalStateContext = new
DelegatingNavigationalStateContext(navigationalStateContext);
+ break;
+ default:
+ throw new AssertionError();
+ }
+
+ //
+ this.portletControllerContext = portletControllerContext;
+ this.navigationalStateContext = navigationalStateContext;
+ this.modifiable = modifiable;
+ }
+
+ public PresentationPortletPageNavigationalState(
+ PresentationPortletPageNavigationalState pageNavigationalState,
+ int mode)
+ {
+ NavigationalStateContext navigationalStateContext =
pageNavigationalState.navigationalStateContext;
+ boolean modifiable;
+ switch (mode)
+ {
+ case READ_ONLY_MODE:
+ modifiable = false;
+ break;
+ case READ_WRITE_MODE:
+ modifiable = true;
+ break;
+ case CLONE_AND_WRITE_MODE:
+ modifiable = true;
+ navigationalStateContext = new
DelegatingNavigationalStateContext(navigationalStateContext);
+ break;
+ default:
+ throw new AssertionError();
+ }
+
+ //
+ this.portletControllerContext = pageNavigationalState.portletControllerContext;
+ this.navigationalStateContext = navigationalStateContext;
+ this.modifiable = modifiable;
+ }
+
+ public void flush()
+ {
+ if (navigationalStateContext instanceof DelegatingNavigationalStateContext)
+ {
+ ((DelegatingNavigationalStateContext)navigationalStateContext).flush(true);
+ }
+ }
+
+ public Set<String> getPortletWindowIds()
+ {
+ return portletControllerContext.getWindowIds();
+ }
+
+ public PortletWindowNavigationalState getPortletWindowNavigationalState(String
portletWindowId) throws IllegalArgumentException
+ {
+ Mode mode = (Mode)navigationalStateContext.getProperty(portletWindowId,
"mode");
+ WindowState windowState =
(WindowState)navigationalStateContext.getProperty(portletWindowId,
"windowstate");
+ StateString portletNavigationalState =
(StateString)navigationalStateContext.getProperty(portletWindowId, "portlet");
+ return new PortletWindowNavigationalState(portletNavigationalState, mode,
windowState);
+ }
+
+ public void setPortletWindowNavigationalState(String portletWindowId,
PortletWindowNavigationalState portletWindowState) throws IllegalArgumentException,
IllegalStateException
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ navigationalStateContext.setProperty(portletWindowId, "windowstate",
portletWindowState.getWindowState());
+ navigationalStateContext.setProperty(portletWindowId, "mode",
portletWindowState.getMode());
+ navigationalStateContext.setProperty(portletWindowId, "portlet",
portletWindowState.getPortletNavigationalState());
+ }
+
+ public Map<String, String[]> getPortletPublicNavigationalState(String
portletWindowId) throws IllegalArgumentException
+ {
+ Map<QName, String[]> pageParameters = (Map<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ Map<String, String[]> portletParameters = null;
+
+ //
+ if (pageParameters != null)
+ {
+ NavigationInfo navigationInfo =
portletControllerContext.getPortletInfo(portletWindowId).getNavigation();
+
+ //
+ for (ParameterInfo parameterInfo : navigationInfo.getPublicParameters())
+ {
+ QName parameterName = parameterInfo.getName();
+ String[] parameterValue = pageParameters.get(parameterName);
+
+ //
+ if (parameterValue != null)
+ {
+ if (portletParameters == null)
+ {
+ portletParameters = new HashMap<String, String[]>();
+ }
+
+ //
+ portletParameters.put(parameterInfo.getId(), parameterValue);
+ }
+ }
+ }
+
+ //
+ return portletParameters;
+ }
+
+ public void setPortletPublicNavigationalState(String portletWindowId, Map<String,
String[]> update) throws IllegalArgumentException, IllegalStateException
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ if (pageParameters == null)
+ {
+ pageParameters = new HashMap<QName, String[]>();
+ }
+
+ //
+ NavigationInfo navigationInfo =
portletControllerContext.getPortletInfo(portletWindowId).getNavigation();
+
+ //
+ for (Map.Entry<String, String[]> entry : update.entrySet())
+ {
+ ParameterInfo parameterInfo =
navigationInfo.getPublicParameter(entry.getKey());
+
+ //
+ QName parameterName = parameterInfo.getName();
+
+ if (entry.getValue().length == 0)
+ {
+ pageParameters.remove(parameterName);
+ }
+ else
+ {
+ pageParameters.put(parameterName, entry.getValue());
+ }
+ }
+
+ //
+ navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
+ }
+
+ public Set<QName> getPublicNames()
+ {
+ HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ return pageParameters != null ? pageParameters.keySet() : null;
+ }
+
+ public String[] getPublicNavigationalState(QName name) throws
IllegalArgumentException
+ {
+ Map<QName, String[]> pageParameters = (Map<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ return pageParameters != null ? pageParameters.get(name) : null;
+ }
+
+ public void setPublicNavigationalState(QName name, String[] value) throws
IllegalArgumentException, IllegalStateException
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ if (pageParameters == null)
+ {
+ pageParameters = new HashMap<QName, String[]>();
+ }
+
+ //
+ pageParameters.put(name, value);
+
+ //
+ navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
+ }
+
+ public void removePublicNavigationalState(QName name) throws IllegalArgumentException,
IllegalStateException
+ {
+ if (!modifiable)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ HashMap<QName, String[]> pageParameters = (HashMap<QName,
String[]>)navigationalStateContext.getProperty(portletControllerContext.getPageId(),
"portlet");
+
+ //
+ if (pageParameters != null)
+ {
+ pageParameters.remove(name);
+
+ //
+ navigationalStateContext.setProperty(portletControllerContext.getPageId(),
"portlet", pageParameters);
+ }
+ }
+}
Copied:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationStateControllerContext.java
(from rev 10724,
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/StructuralStateControllerContext.java)
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationStateControllerContext.java
(rev 0)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/controller/PresentationStateControllerContext.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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.presentation.portlet.controller;
+
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationStateControllerContext implements StateControllerContext
+{
+
+ /** . */
+ private PresentationPortletControllerContext portletControllerContext;
+
+ public PresentationStateControllerContext(PresentationPortletControllerContext
portletControllerContext)
+ {
+ this.portletControllerContext = portletControllerContext;
+ }
+
+ public PortletPageNavigationalState
clonePortletPageNavigationalState(PortletPageNavigationalState
portletPageNavigationalState, boolean modifiable)
+ {
+
+ return new PresentationPortletPageNavigationalState(
+ (PresentationPortletPageNavigationalState)portletPageNavigationalState,
+ modifiable ? PresentationPortletPageNavigationalState.CLONE_AND_WRITE_MODE :
PresentationPortletPageNavigationalState.READ_ONLY_MODE);
+ }
+
+ public PortletPageNavigationalState createPortletPageNavigationalState(boolean
modifiable)
+ {
+ return new PresentationPortletPageNavigationalState(
+ portletControllerContext,
+ new NavigationalStateContextImpl(),
+ modifiable ? PresentationPortletPageNavigationalState.READ_WRITE_MODE :
PresentationPortletPageNavigationalState.READ_ONLY_MODE);
+ }
+}
Modified:
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/spi/PresentationPortletInvocationContext.java
===================================================================
---
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/spi/PresentationPortletInvocationContext.java 2008-04-28
11:26:46 UTC (rev 10725)
+++
modules/presentation/trunk/portlet/src/main/java/org/jboss/portal/presentation/portlet/spi/PresentationPortletInvocationContext.java 2008-04-28
11:29:14 UTC (rev 10726)
@@ -28,7 +28,7 @@
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.net.media.MediaType;
import org.jboss.portal.presentation.portlet.protocol.PortletContainerAction;
-import
org.jboss.portal.presentation.portlet.controller.StructuralPortletControllerContext;
+import
org.jboss.portal.presentation.portlet.controller.PresentationPortletControllerContext;
import org.jboss.portal.presentation.client.PresentationClient;
import java.io.Writer;
@@ -45,7 +45,7 @@
private final MarkupInfo markup = new MarkupInfo(MediaType.TEXT_HTML,
"UTF-8");
/** . */
- private final StructuralPortletControllerContext portletControllerContext;
+ private final PresentationPortletControllerContext portletControllerContext;
/** . */
private final String windowId;
@@ -55,7 +55,7 @@
public PresentationPortletInvocationContext(
PresentationClient client,
- StructuralPortletControllerContext portletControllerContext,
+ PresentationPortletControllerContext portletControllerContext,
String windowId)
{
this.client = client;