Author: julien(a)jboss.com
Date: 2008-04-27 16:25:19 -0400 (Sun, 27 Apr 2008)
New Revision: 10720
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/PortletContainerAction.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/DelegatingNavigationalStateContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextSerialization.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/CommandAction.java
Modified:
modules/presentation/trunk/classic/pom.xml
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java
modules/presentation/trunk/presentation/pom.xml
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/PresentationServerImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletControllerContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletPageNavigationalState.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralStateControllerContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/spi/PresentationPortletInvocationContext.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java
Log:
a basic integration with page navigational state in PF
Modified: modules/presentation/trunk/classic/pom.xml
===================================================================
--- modules/presentation/trunk/classic/pom.xml 2008-04-26 20:51:08 UTC (rev 10719)
+++ modules/presentation/trunk/classic/pom.xml 2008-04-27 20:25:19 UTC (rev 10720)
@@ -36,6 +36,11 @@
</dependency>
<dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.portal.common</groupId>
<artifactId>common-portal</artifactId>
</dependency>
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/ClassicPresentationClient.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -31,6 +31,7 @@
import org.jboss.portal.presentation.classic.protocol.ActionEncoder;
import org.jboss.portal.presentation.client.PresentationClient;
import org.jboss.portal.presentation.impl.model.UIModelImpl;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.ViewPort;
@@ -77,28 +78,49 @@
protected final PresentationServer server;
/** . */
- protected final ActionDecoder decoder = new ActionDecoder();
+ protected ActionEncoder encoder;
/** . */
- protected final ActionEncoder encoder = new ActionEncoder();
+ protected final ProtocolAction protocolAction;
+ /** . */
+ protected final NavigationalStateContext navigationalStateContext;
+
public ClassicPresentationClient(
WebRequest req,
WebResponse resp,
PresentationServer server)
{
+ ActionDecoder decoder = new ActionDecoder();
+ decoder.decode(req);
+
+ //
+ NavigationalStateContext navigationalStateContext =
decoder.getNavigationalStateContext();
+ if (navigationalStateContext == null)
+ {
+ navigationalStateContext = new NavigationalStateContextImpl();
+ }
+
+ //
this.req = req;
this.resp = resp;
this.server = server;
+ this.protocolAction = decoder.getProtocolAction();
+ this.navigationalStateContext = navigationalStateContext;
+ this.encoder = null;
}
public NavigationalStateContext getNavigationalStateContext()
{
- return null;
+ return navigationalStateContext;
}
public String renderURL(ProtocolAction action, URLFormat format) throws
IllegalArgumentException
{
+ if (encoder == null)
+ {
+ throw new IllegalStateException("It is not possible to render an URL during
the process of an action");
+ }
if (action == null)
{
throw new IllegalArgumentException("No null action can be rendered");
@@ -136,13 +158,12 @@
public void process() throws IOException, PresentationServerException
{
- ProtocolAction action = decoder.decode(req);
PresentationResponse presentationResp = null;
- if (action != null)
+ if (protocolAction != null)
{
- PresentationRequest request = new PresentationRequest(action);
+ PresentationRequest request = new PresentationRequest(protocolAction);
presentationResp = server.process(this, request);
}
@@ -173,6 +194,9 @@
private void renderDocument(ViewPortScope scope, String nodeId) throws IOException
{
+ encoder = new
ActionEncoder((NavigationalStateContextImpl)navigationalStateContext);
+
+ //
StructuralStateContext ssc = server.getStructuralStateContext();
ClassicViewPortContext context = new ClassicViewPortContext();
UIModel model = new UIModelImpl(null, ssc);
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionDecoder.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -26,8 +26,23 @@
import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.impl.server.portlet.PortletContainerAction;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextSerialization;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
import org.jboss.portal.web.WebRequest;
+import org.jboss.portal.web.Body;
+import org.jboss.portal.portlet.LifeCyclePhase;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.common.util.Base64;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -35,8 +50,24 @@
public class ActionDecoder
{
- public ProtocolAction decode(WebRequest request)
+ /** The protocol action. */
+ private ProtocolAction protocolAction;
+
+ /** . */
+ private NavigationalStateContext navigationalStateContext;
+
+ public ProtocolAction getProtocolAction()
{
+ return protocolAction;
+ }
+
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ return navigationalStateContext;
+ }
+
+ public void decode(WebRequest request)
+ {
ProtocolAction action = null;
//
@@ -71,14 +102,67 @@
switch (request.getVerb())
{
case GET:
- return new GetActivation(targetId, path, request.getQueryParameterMap());
+ action= new GetActivation(targetId, path,
request.getQueryParameterMap());
+ break;
case POST:
- return new PostActivation(targetId, path, request.getQueryParameterMap(),
request.getBody());
+ action = new PostActivation(targetId, path,
request.getQueryParameterMap(), request.getBody());
+ break;
+ default:
+ throw new NotYetImplemented();
}
}
+ else if (webPath.startsWith("/portlet/"))
+ {
+ String targetId = webPath.substring("/portlet/".length());
+ //
+ LifeCyclePhase phase =
LifeCyclePhase.valueOf(request.getQueryParameter("phase"));
+
+ //
+ String stateString = request.getQueryParameter("state");
+ StateString state = stateString != null ?
ParametersStateString.create(stateString) : null;
+
+ //
+ String windowStateString = request.getQueryParameter("ws");
+ WindowState windowState = windowStateString != null ?
WindowState.create(windowStateString) : null;
+
+ //
+ String modeString = request.getQueryParameter("mode");
+ Mode mode = modeString != null ? Mode.create(modeString) : null;
+
+ //
+ Map<String, String[]> form = null;
+ if (request.getBody() instanceof Body.Form)
+ {
+ form = ((Body.Form)request.getBody()).getParameters();
+ }
+
+ //
+ switch (phase)
+ {
+ case ACTION:
+ action = PortletContainerAction.createAction(targetId, mode, windowState,
state, form);
+ break;
+ case RENDER:
+ action = PortletContainerAction.createRender(targetId, state, mode,
windowState, null);
+ break;
+ default:
+ throw new NotYetImplemented();
+ }
+ }
+
//
- return action;
+ String nsString = request.getQueryParameter("ns");
+ NavigationalStateContext navigationalStateContext = null;
+ if (nsString != null)
+ {
+ byte[] bytes = Base64.decode(nsString, true);
+ NavigationalStateContextSerialization serialization = new
NavigationalStateContextSerialization();
+ navigationalStateContext = IOTools.unserialize(serialization,
SerializationFilter.COMPRESSOR ,bytes);
+ }
+
+ //
+ this.protocolAction = action;
+ this.navigationalStateContext = navigationalStateContext;
}
-
}
Modified:
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java
===================================================================
---
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presentation/classic/protocol/ActionEncoder.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -27,8 +27,17 @@
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.UIObjectAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.impl.server.portlet.PortletContainerAction;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextSerialization;
import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.SerializationFilter;
+import org.jboss.portal.common.util.Base64;
+import java.util.Map;
+import java.util.HashMap;
+
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -36,6 +45,19 @@
public class ActionEncoder
{
+ /** An optional navigational state. */
+ private String ns;
+
+ public ActionEncoder()
+ {
+ }
+
+ public ActionEncoder(NavigationalStateContextImpl navigationalStateContext)
+ {
+ byte[] bytes = IOTools.serialize(new NavigationalStateContextSerialization(),
SerializationFilter.COMPRESSOR, navigationalStateContext);
+ ns = Base64.encodeBytes(bytes, true);
+ }
+
public String encode(ProtocolAction action, WebResponse resp)
{
if (action instanceof UIObjectAction)
@@ -57,10 +79,46 @@
//
return resp.renderURL("/invoke/" + targetId,
linkActivationAction.getQueryParameters(), null);
}
+ else if (action instanceof PortletContainerAction)
+ {
+ PortletContainerAction pcAction = (PortletContainerAction)action;
+
+ //
+ Map<String, String[]> parameters = new HashMap<String,
String[]>();
+
+ //
+ if (pcAction.getState() != null)
+ {
+ parameters.put("state", new
String[]{pcAction.getState().getStringValue()});
+ }
+
+ //
+ if (pcAction.getMode() != null)
+ {
+ parameters.put("mode", new
String[]{pcAction.getMode().toString()});
+ }
+
+ //
+ if (pcAction.getWindowState() != null)
+ {
+ parameters.put("ws", new
String[]{pcAction.getWindowState().toString()});
+ }
+
+ //
+ if (ns != null)
+ {
+ parameters.put("ns", new String[]{ns});
+ }
+
+ //
+ parameters.put("phase", new
String[]{pcAction.getPhase().toString()});
+
+ //
+ return resp.renderURL("/portlet/" + targetId, parameters, null);
+ }
}
//
return null;
}
-
}
Modified: modules/presentation/trunk/presentation/pom.xml
===================================================================
--- modules/presentation/trunk/presentation/pom.xml 2008-04-26 20:51:08 UTC (rev 10719)
+++ modules/presentation/trunk/presentation/pom.xml 2008-04-27 20:25:19 UTC (rev 10720)
@@ -13,18 +13,22 @@
<name>JBoss Portal Presentation Framework - Presentation Module</name>
<dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.portal.portlet</groupId>
- <artifactId>portlet-portlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.portal.portlet</groupId>
- <artifactId>portlet-controller</artifactId>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.portlet</groupId>
+ <artifactId>portlet-portlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.portlet</groupId>
+ <artifactId>portlet-controller</artifactId>
+ </dependency>
</dependencies>
<build>
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/PresentationServerImpl.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/PresentationServerImpl.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -28,6 +28,8 @@
import org.jboss.portal.presentation.impl.state.structural.WindowNode;
import org.jboss.portal.presentation.impl.state.structural.PageNode;
import
org.jboss.portal.presentation.impl.server.portlet.StructuralPortletControllerContext;
+import org.jboss.portal.presentation.impl.server.portlet.PortletContainerAction;
+import
org.jboss.portal.presentation.impl.server.portlet.StructuralPortletPageNavigationalState;
import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.protocol.ErrorResponse;
import org.jboss.portal.presentation.protocol.ProtocolAction;
@@ -35,7 +37,6 @@
import org.jboss.portal.presentation.protocol.UIObjectAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
import org.jboss.portal.presentation.protocol.LinkActivation;
-import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.server.PresentationRequest;
import org.jboss.portal.presentation.server.PresentationResponse;
import org.jboss.portal.presentation.server.PresentationServer;
@@ -44,18 +45,18 @@
import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.controller.impl.ControllerRequestFactory;
import org.jboss.portal.portlet.controller.request.ControllerRequest;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
+import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
import org.jboss.portal.portlet.controller.PortletController;
+import org.jboss.portal.portlet.controller.state.PortletWindowNavigationalState;
import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.web.Body;
+import org.jboss.portal.common.NotYetImplemented;
-import java.util.Map;
-
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
* @version $Revision: 630 $
@@ -103,8 +104,14 @@
page,
portletInvoker);
- PortletInvocationResponse response = controller.render(portletControllerContext,
null, null, windowId);
+ //
+ StructuralPortletPageNavigationalState pageNavigationalState = new
StructuralPortletPageNavigationalState(
+ portletControllerContext,
+ client.getNavigationalStateContext(),
+ StructuralPortletPageNavigationalState.READ_ONLY_MODE);
+ PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, windowId);
+
//
if (response instanceof FragmentResponse)
{
@@ -149,61 +156,88 @@
}
else if (objectAction instanceof LinkActivation)
{
- LinkActivation linkActivation = (LinkActivation)objectAction;
+ throw new NotYetImplemented();
+ }
+ else if (objectAction instanceof PortletContainerAction)
+ {
+ PortletContainerAction pcAction = (PortletContainerAction)objectAction;
//
- if (targetNode instanceof WindowNode)
- {
- WindowNode targetWindow = (WindowNode)targetNode;
+ WindowNode targetWindow = (WindowNode)targetNode;
- //
- PageNode targetPage = (PageNode)targetWindow.getParent();
+ //
+ PageNode targetPage = (PageNode)targetWindow.getParent();
- //
- ControllerRequestFactory factory = new ControllerRequestFactory(null);
+ //
+ StructuralPortletControllerContext portletControllerContext = new
StructuralPortletControllerContext(
+ client,
+ targetPage,
+ portletInvoker);
- Body body = null;
- if (linkActivation instanceof PostActivation)
- {
- body = ((PostActivation)linkActivation).getBody();
- }
+ StructuralPortletPageNavigationalState pageNavigationalState = new
StructuralPortletPageNavigationalState(
+ portletControllerContext,
+ client.getNavigationalStateContext(),
+ StructuralPortletPageNavigationalState.CLONE_AND_WRITE_MODE);
- //
- ControllerRequest controllerRequest =
factory.decode(linkActivation.getQueryParameters(), body);
+ //
+ ControllerRequest controllerRequest;
+ switch (pcAction.getPhase())
+ {
+ case ACTION:
+ controllerRequest = new PortletActionRequest(
+ targetWindow.getId(),
+ pcAction.getState(),
+ pcAction.getForm(),
+
pageNavigationalState.getPortletWindowNavigationalState(targetWindow.getId()),
+ pageNavigationalState
+ );
+ break;
+ case RENDER:
+ PortletWindowNavigationalState windowNavigationalState = new
PortletWindowNavigationalState(
+ pcAction.getState(),
+ pcAction.getMode(),
+ pcAction.getWindowState()
+ );
+ controllerRequest = new PortletRenderRequest(
+ targetWindow.getId(),
+ windowNavigationalState,
+ null,
+ pageNavigationalState
+ );
+ break;
+ default:
+ throw new NotYetImplemented();
+ }
- //
- PortletController controller = new PortletController();
+ //
+ PortletController controller = new PortletController();
- //
- StructuralPortletControllerContext portletControllerContext = new
StructuralPortletControllerContext(
- client,
- targetPage,
- portletInvoker);
+ //
+ try
+ {
+ ControllerResponse response = controller.process(portletControllerContext,
controllerRequest);
- //
- try
+ if (response instanceof PageUpdateResponse)
{
- ControllerResponse response =
controller.process(portletControllerContext, controllerRequest);
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
- if (response instanceof PageUpdateResponse)
- {
- PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
+ //
+ NavigationalStateContext nsc = client.getNavigationalStateContext();
- //
- NavigationalStateContext nsc =
client.getNavigationalStateContext();
+ //
+ StructuralPortletPageNavigationalState blah =
(StructuralPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
- //
- PortletPageNavigationalState blah =
pageUpdate.getPageNavigationalState();
- }
+ //
+ blah.flush();
}
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
- //
- return new PresentationResponse(new
ShowUIObjectResponse(targetPage.getId()));
- }
+ //
+ return new PresentationResponse(new
ShowUIObjectResponse(targetPage.getId()));
}
}
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/PortletContainerAction.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/PortletContainerAction.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/PortletContainerAction.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -0,0 +1,168 @@
+/******************************************************************************
+ * 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.impl.server.portlet;
+
+import org.jboss.portal.presentation.protocol.CommandAction;
+import org.jboss.portal.portlet.LifeCyclePhase;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContainerAction extends CommandAction
+{
+
+ /** The portlet phase. */
+ private final LifeCyclePhase phase;
+
+ /** The navigational state. */
+ private final StateString state;
+
+ /** . */
+ private final Map<String, String[]> form;
+
+ /** . */
+ private final Mode mode;
+
+ /** . */
+ private final WindowState windowState;
+
+ /** . */
+ private final Map<String, String[]> publicNavigationalStateChanges;
+
+ private PortletContainerAction(
+ String targetId,
+ LifeCyclePhase phase,
+ StateString state,
+ Mode mode,
+ WindowState windowState,
+ Map<String, String[]> publicNavigationalStateChanges,
+ Map<String, String[]> form) throws IllegalArgumentException
+ {
+ super(targetId);
+
+ //
+ this.phase = phase;
+ this.state = state;
+ this.mode = mode;
+ this.windowState = windowState;
+ this.publicNavigationalStateChanges = publicNavigationalStateChanges;
+ this.form = form;
+ }
+
+ public LifeCyclePhase getPhase()
+ {
+ return phase;
+ }
+
+ public StateString getState()
+ {
+ return state;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
+ {
+ return publicNavigationalStateChanges;
+ }
+
+ public Map<String, String[]> getForm()
+ {
+ return form;
+ }
+
+ public static PortletContainerAction create(String targetId, ContainerURL
containerURL)
+ {
+ if (containerURL instanceof RenderURL)
+ {
+ RenderURL renderURL = (RenderURL)containerURL;
+
+ //
+ return new PortletContainerAction(
+ targetId,
+ LifeCyclePhase.RENDER,
+ renderURL.getNavigationalState(),
+ renderURL.getMode(),
+ renderURL.getWindowState(),
+ renderURL.getPublicNavigationalStateChanges(),
+ null);
+
+ }
+ else if (containerURL instanceof ActionURL)
+ {
+ ActionURL actionURL = (ActionURL)containerURL;
+
+ //
+ return new PortletContainerAction(
+ targetId,
+ LifeCyclePhase.ACTION,
+ actionURL.getInteractionState(),
+ actionURL.getMode(),
+ actionURL.getWindowState(),
+ null,
+ null);
+ }
+ else
+ {
+ throw new NotYetImplemented();
+ }
+ }
+
+ public static PortletContainerAction createRender(
+ String targetId,
+ StateString navigationalState,
+ Mode mode,
+ WindowState windowState,
+ Map<String, String[]> publicNavigationalStateChanges)
+ {
+ return new PortletContainerAction(targetId, LifeCyclePhase.RENDER,
navigationalState, mode, windowState, publicNavigationalStateChanges, null);
+ }
+
+ public static PortletContainerAction createAction(
+ String targetId,
+ Mode mode,
+ WindowState windowState,
+ StateString interactionState,
+ Map<String, String[]> form)
+ {
+ return new PortletContainerAction(targetId, LifeCyclePhase.ACTION,
interactionState, mode, windowState, null, form);
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletControllerContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletControllerContext.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletControllerContext.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -123,7 +123,7 @@
this.client = client;
this.page = page;
this.invoker = invoker;
- this.stateControllerContext = new StructuralStateControllerContext(this,
client.getNavigationalStateContext());
+ this.stateControllerContext = new StructuralStateControllerContext(this);
this.portlets = portlets;
this.windows = windows;
this.eventControllerContext = new StructuralEventControllerContext(this);
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletPageNavigationalState.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletPageNavigationalState.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralPortletPageNavigationalState.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -28,6 +28,7 @@
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;
@@ -44,17 +45,87 @@
{
/** . */
+ 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 StructuralPortletControllerContext portletControllerContext;
/** . */
private final NavigationalStateContext navigationalStateContext;
- public StructuralPortletPageNavigationalState(StructuralPortletControllerContext
portletControllerContext, NavigationalStateContext navigationalStateContext)
+ /** . */
+ private final boolean modifiable;
+
+ public StructuralPortletPageNavigationalState(
+ StructuralPortletControllerContext 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 StructuralPortletPageNavigationalState(
+ StructuralPortletPageNavigationalState 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();
@@ -62,14 +133,20 @@
public PortletWindowNavigationalState getPortletWindowNavigationalState(String
portletWindowId) throws IllegalArgumentException
{
- Mode mode = (Mode)navigationalStateContext.getProperty(portletWindowId,
"windowstate");
- WindowState windowState =
(WindowState)navigationalStateContext.getProperty(portletWindowId, "mode");
+ 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());
@@ -113,6 +190,12 @@
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");
//
@@ -132,7 +215,7 @@
//
QName parameterName = parameterInfo.getName();
- if (entry.getValue().length > 0)
+ if (entry.getValue().length == 0)
{
pageParameters.remove(parameterName);
}
@@ -164,6 +247,12 @@
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");
//
@@ -181,6 +270,12 @@
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");
//
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralStateControllerContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralStateControllerContext.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/StructuralStateControllerContext.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.portlet.controller.state.PortletPageNavigationalState;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -36,22 +36,24 @@
/** . */
private StructuralPortletControllerContext portletControllerContext;
- /** . */
- private NavigationalStateContext navigationalStateContext;
-
- public StructuralStateControllerContext(StructuralPortletControllerContext
portletControllerContext, NavigationalStateContext navigationalStateContext)
+ public StructuralStateControllerContext(StructuralPortletControllerContext
portletControllerContext)
{
this.portletControllerContext = portletControllerContext;
- this.navigationalStateContext = navigationalStateContext;
}
public PortletPageNavigationalState
clonePortletPageNavigationalState(PortletPageNavigationalState
portletPageNavigationalState, boolean modifiable)
{
- return new StructuralPortletPageNavigationalState(portletControllerContext,
navigationalStateContext);
+
+ return new StructuralPortletPageNavigationalState(
+ (StructuralPortletPageNavigationalState)portletPageNavigationalState,
+ modifiable ? StructuralPortletPageNavigationalState.CLONE_AND_WRITE_MODE :
StructuralPortletPageNavigationalState.READ_ONLY_MODE);
}
public PortletPageNavigationalState createPortletPageNavigationalState(boolean
modifiable)
{
- return new StructuralPortletPageNavigationalState(portletControllerContext,
navigationalStateContext);
+ return new StructuralPortletPageNavigationalState(
+ portletControllerContext,
+ new NavigationalStateContextImpl(),
+ modifiable ? StructuralPortletPageNavigationalState.READ_WRITE_MODE :
StructuralPortletPageNavigationalState.READ_ONLY_MODE);
}
}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/spi/PresentationPortletInvocationContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/spi/PresentationPortletInvocationContext.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/server/portlet/spi/PresentationPortletInvocationContext.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -25,20 +25,14 @@
import org.jboss.portal.portlet.spi.PortletInvocationContext;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.URLFormat;
-import org.jboss.portal.portlet.controller.impl.PortletURLRenderer;
-import org.jboss.portal.portlet.controller.impl.ControllerRequestParameterMapFactory;
-import
org.jboss.portal.portlet.controller.state.PortletPageNavigationalStateSerialization;
-import org.jboss.portal.portlet.controller.state.StateControllerContext;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.net.media.MediaType;
import
org.jboss.portal.presentation.impl.server.portlet.StructuralPortletControllerContext;
-import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.impl.server.portlet.PortletContainerAction;
import org.jboss.portal.presentation.client.PresentationClient;
import java.io.Writer;
import java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -86,22 +80,28 @@
public String renderURL(ContainerURL containerURL, URLFormat format)
{
- StateControllerContext stateControllerContext =
portletControllerContext.getStateControllerContext();
- PortletPageNavigationalStateSerialization serialiation = new
PortletPageNavigationalStateSerialization(stateControllerContext);
- ControllerRequestParameterMapFactory parameterMapFactory = new
ControllerRequestParameterMapFactory(serialiation);
+ PortletContainerAction action = PortletContainerAction.create(windowId,
containerURL);
- Map<String, String> parameters = parameterMapFactory.encode(null, windowId,
containerURL);
+ //
+ String url = client.renderURL(action, null);
- Map<String, String[]> blah = new HashMap<String, String[]>();
- for (Map.Entry<String, String> entry : parameters.entrySet())
- {
- blah.put(entry.getKey(), new String[]{entry.getValue()});
- }
- GetActivation getActivation = new GetActivation(windowId, "/", blah);
+// StateControllerContext stateControllerContext =
portletControllerContext.getStateControllerContext();
+// PortletPageNavigationalStateSerialization serialiation = new
PortletPageNavigationalStateSerialization(stateControllerContext);
+// ControllerRequestParameterMapFactory parameterMapFactory = new
ControllerRequestParameterMapFactory(serialiation);
+//
+// Map<String, String> parameters = parameterMapFactory.encode(null, windowId,
containerURL);
+//
+// Map<String, String[]> blah = new HashMap<String, String[]>();
+// for (Map.Entry<String, String> entry : parameters.entrySet())
+// {
+// blah.put(entry.getKey(), new String[]{entry.getValue()});
+// }
+//
+// GetActivation getActivation = new GetActivation(windowId, "/", blah);
+//
+// String url = client.renderURL(getActivation, null);
- String url = client.renderURL(getActivation, null);
-
return url;
}
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/DelegatingNavigationalStateContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/DelegatingNavigationalStateContext.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/DelegatingNavigationalStateContext.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -0,0 +1,177 @@
+/******************************************************************************
+ * 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.impl.state.navigational;
+
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.state.StateException;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class DelegatingNavigationalStateContext implements NavigationalStateContext
+{
+
+ /** . */
+ private NavigationalStateContext delegate;
+
+ /** . */
+ private Map<String, Map<String, Serializable>> updates;
+
+ public DelegatingNavigationalStateContext(NavigationalStateContext delegate)
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("No null delegate accepted");
+ }
+
+ //
+ this.delegate = delegate;
+ }
+
+ public Set<String> getPropertyNames(String objectId)
+ {
+ Map<String, Serializable> properties = getProperties(objectId, false);
+
+ //
+ if (properties == null)
+ {
+ return delegate.getPropertyNames(objectId);
+ }
+ else
+ {
+ return properties.keySet();
+ }
+ }
+
+ public Serializable getProperty(String objectId, String key) throws
IllegalArgumentException
+ {
+ Map<String, Serializable> properties = getProperties(objectId, false);
+
+ //
+ if (properties == null)
+ {
+ return delegate.getProperty(objectId, key);
+ }
+ else
+ {
+ return properties.get(key);
+ }
+ }
+
+ public void setProperty(String objectId, String key, Serializable navigationalState)
throws StateException, IllegalArgumentException
+ {
+ Map<String, Serializable> properties = getProperties(objectId, true);
+
+ //
+ properties.put(key, navigationalState);
+ }
+
+ public NavigationalStateContext getDelegate()
+ {
+ return delegate;
+ }
+
+ public void flush(boolean deep)
+ {
+ if (updates != null)
+ {
+ for (Map.Entry<String, Map<String, Serializable>> update :
updates.entrySet())
+ {
+ String objectId = update.getKey();
+ Map<String, Serializable> properties = update.getValue();
+
+ //
+ for (Map.Entry<String, Serializable> property : properties.entrySet())
+ {
+ delegate.setProperty(objectId, property.getKey(), property.getValue());
+ }
+ }
+
+ //
+ if (deep && delegate instanceof DelegatingNavigationalStateContext)
+ {
+ ((DelegatingNavigationalStateContext)delegate).flush(true);
+ }
+ }
+ }
+
+ public void clear(boolean deep)
+ {
+ updates.clear();
+
+ //
+ if (deep && delegate instanceof DelegatingNavigationalStateContext)
+ {
+ ((DelegatingNavigationalStateContext)delegate).clear(true);
+ }
+ }
+
+ private Map<String, Serializable> getProperties(String objectId, boolean
create)
+ {
+ if (create)
+ {
+ if (updates == null)
+ {
+ updates = new HashMap<String, Map<String, Serializable>>();
+ }
+
+ //
+ Map<String, Serializable> properties = updates.get(objectId);
+
+ //
+ if (properties == null)
+ {
+ properties = new HashMap<String, Serializable>();
+
+ //
+ Set<String> propertyNames = delegate.getPropertyNames(objectId);
+
+ //
+ if (propertyNames != null)
+ {
+ for (String propertyName : propertyNames)
+ {
+ Serializable propertyValue = delegate.getProperty(objectId,
propertyName);
+ properties.put(propertyName, propertyValue);
+ }
+ }
+
+ //
+ updates.put(objectId, properties);
+ }
+
+ //
+ return properties;
+ }
+ else
+ {
+ return updates != null ? updates.get(objectId) : null;
+ }
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -32,17 +32,26 @@
import java.io.Serializable;
/**
+ * An implementation of the {@link
org.jboss.portal.presentation.state.navigational.NavigationalStateContext} interface
+ * that is serializable.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class NavigationalStateContextImpl implements NavigationalStateContext
+public class NavigationalStateContextImpl implements NavigationalStateContext,
Serializable
{
/** . */
- private final Map<String, Map<String, Serializable>> map;
+ final Map<String, Map<String, Serializable>> map;
public NavigationalStateContextImpl(Map<String, Map<String, Serializable>>
map)
{
+ if (map == null)
+ {
+ throw new IllegalArgumentException("No null map provided");
+ }
+
+ //
this.map = map;
}
@@ -59,7 +68,10 @@
}
//
- return map.get(objectId).keySet();
+ Map<String, Serializable> properties = map.get(objectId);
+
+ //
+ return properties != null ? properties.keySet() : null;
}
public void setProperty(String objectId, String key, Serializable navigationalState)
throws StateChangeVetoException, StateException, IllegalArgumentException
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextSerialization.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextSerialization.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextSerialization.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * 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.impl.state.navigational;
+
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.DataOutputStream;
+import java.io.DataInputStream;
+
+/**
+ * A basic implementation.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NavigationalStateContextSerialization implements
Serialization<NavigationalStateContext>
+{
+
+ public NavigationalStateContextSerialization()
+ {
+ }
+
+ public void serialize(NavigationalStateContext navigationalStateContext, OutputStream
out) throws IOException, IllegalArgumentException
+ {
+ NavigationalStateContextImpl tmp =
(NavigationalStateContextImpl)navigationalStateContext;
+
+ // Serialize to bytes
+ byte[] bytes = IOTools.serialize(tmp);
+
+ // See if we can reuse an existing data output stream
+ DataOutputStream dataOut = out instanceof DataOutputStream ? (DataOutputStream)out
: new DataOutputStream(out);
+
+ // Write data
+ dataOut.writeInt(bytes.length);
+ dataOut.write(bytes);
+
+ // We only need to flush if we have our own data stream
+ if (!(out instanceof DataOutputStream))
+ {
+ dataOut.flush();
+ }
+ }
+
+ public NavigationalStateContext unserialize(InputStream in) throws IOException,
IllegalArgumentException
+ {
+ DataInputStream dataIn = in instanceof DataInputStream ? (DataInputStream)in : new
DataInputStream(in);
+
+ //
+ int length = dataIn.readInt();
+ byte[] bytes = new byte[length];
+ dataIn.readFully(bytes);
+
+ //
+ try
+ {
+ return (NavigationalStateContext)IOTools.unserialize(bytes);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // Need to improve that later
+ throw new Error(e);
+ }
+ }
+}
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/CommandAction.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/CommandAction.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/CommandAction.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * 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.protocol;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class CommandAction extends UIObjectAction
+{
+ protected CommandAction(String targetId) throws IllegalArgumentException
+ {
+ super(targetId);
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java 2008-04-26
20:51:08 UTC (rev 10719)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/state/navigational/NavigationalStateContext.java 2008-04-27
20:25:19 UTC (rev 10720)
@@ -28,6 +28,8 @@
import java.io.Serializable;
/**
+ * Note that this object itself is not serializable on purpose as it may contain
references to non serializable object.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/