Author: julien(a)jboss.com
Date: 2007-11-18 19:08:14 -0500 (Sun, 18 Nov 2007)
New Revision: 9017
Added:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationActionContext.java
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java
Modified:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/PresentationContentRendererContext.java
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationRenderContext.java
branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml
Log:
basic support for portlet container
Modified:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
---
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-18
23:19:13 UTC (rev 9016)
+++
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-19
00:08:14 UTC (rev 9017)
@@ -33,6 +33,8 @@
import org.jboss.portal.presentation.protocol.ServerAction;
import org.jboss.portal.presentation.protocol.GetActivation;
import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.ErrorResponse;
+import org.jboss.portal.presentation.protocol.ServerResponse;
import org.jboss.portal.presentation.server.Processor;
import org.jboss.portal.presentation.server.ProcessorRequest;
import org.jboss.portal.presentation.server.ProcessorResponse;
@@ -42,10 +44,25 @@
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.portlet.WindowContextImpl;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.CustomizationManager;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationActionContext;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationRenderContext;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationRequestContext;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationPortalContext;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationUserContext;
+import
org.jboss.portal.core.presentation.server.content.portlet.PresentationSecurityContext;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -60,6 +77,9 @@
/** . */
private PortalObjectContainer portalObjectContainer;
+ /** . */
+ private CustomizationManager customizationManager;
+
public PortalObjectContainer getPortalObjectContainer()
{
return portalObjectContainer;
@@ -70,6 +90,16 @@
this.portalObjectContainer = portalObjectContainer;
}
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
/**
*
*/
@@ -77,7 +107,6 @@
{
try
{
- ProcessorResponse response = null;
//For now, just for prototype sake just use the existing Controller to produce
the outcome
/*requestContext.getInvocation().setHandler(new
RequestControllerDispatcher(this.requestController));
requestContext.getInvocation().invokeNext();
@@ -131,63 +160,96 @@
response = new ProcessorResponse(errorResponse);
}*/
ServerAction serverAction = request.getAction();
+
+ ServerResponse response = null;
+
if(serverAction instanceof ViewUIObjectAction)
{
ViewUIObjectAction viewAction = (ViewUIObjectAction)serverAction;
- ShowUIObjectResponse actionResponse = new
ShowUIObjectResponse(viewAction.getTargetId());
- response = new ProcessorResponse(actionResponse);
+ response = new ShowUIObjectResponse(viewAction.getTargetId());
}
else if (serverAction instanceof LinkActivation)
{
LinkActivation getActivation = (LinkActivation)serverAction;
String id = getActivation.getTargetId();
PortalObjectId poid = PortalObjectId.parse(id,
PortalObjectPath.CANONICAL_FORMAT);
- Window target = (Window)portalObjectContainer.getObject(poid);
+ Window window = (Window)portalObjectContainer.getObject(poid);
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(getActivation.getQueryParameters(), null);
// We assume that for now
- UIWindow window =
(UIWindow)presentationContext.getUIContext().getObject(id);
+ UIWindow uiWindow =
(UIWindow)presentationContext.getUIContext().getObject(id);
//
- switch(decoder.getType())
+ WindowState windowState = decoder.getWindowState();
+ Mode mode = decoder.getMode();
+ StateString contentState = decoder.getNavigationalState();
+
+ //
+ if (decoder.getType() == PortletRequestDecoder.ACTION_TYPE)
{
- case PortletRequestDecoder.ACTION_TYPE:
+ if (windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ }
+ if (mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+ WindowNavigationalState wns = new WindowNavigationalState(windowState,
mode, contentState);
+ PresentationActionContext actionContext = new
PresentationActionContext(uiWindow, wns, presentationContext,
decoder.getInteractionState(), decoder.getForm());
+ ActionInvocation action = new ActionInvocation(actionContext);
+ action.setRequestContext(new
PresentationRequestContext(presentationContext));
+ action.setWindowContext(new WindowContextImpl(window));
+ action.setPortalContext(new PresentationPortalContext());
+ action.setUserContext(new PresentationUserContext());
+ action.setSecurityContext(new PresentationSecurityContext());
- System.out.println("TODO implement process action");
+ // We need the user id
+ User user = null; // Null for now
+ // Get instance
+ Instance instance = customizationManager.getInstance(window, user);
- break;
- case PortletRequestDecoder.NAV_TYPE:
- case PortletRequestDecoder.RENDER_TYPE:
+ //
+ PortletInvocationResponse pir = instance.invoke(action);
- //
- WindowState windowState = decoder.getWindowState();
- if (windowState != null)
- {
- window.setWindowState(windowState);
- }
+ //
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse render = (RenderResponse)pir;
+ windowState = render.getWindowState();
+ mode = render.getMode();
+ contentState = render.getNavigationalState();
+ }
+ else
+ {
+ System.out.println("TODO implement portlet invocation response
handling for " + pir);
//
- Mode mode = decoder.getMode();
- if (mode != null)
- {
- window.setMode(mode);
- }
+ response = new ErrorResponse(500);
+ }
+ }
- // Update parameters
- StateString contentState = decoder.getNavigationalState();
- window.setContentState(contentState);
-
- //
- break;
+ // It means we went through a successful action or it is a render
+ if (response == null)
+ {
+ // Update navigational state
+ if (windowState != null)
+ {
+ uiWindow.setWindowState(windowState);
+ }
+ if (mode != null)
+ {
+ uiWindow.setMode(mode);
+ }
+ uiWindow.setContentState(contentState);
+ response = new
ShowUIObjectResponse(window.getPage().getId().toString(PortalObjectPath.CANONICAL_FORMAT));
}
+ }
- //
- ShowUIObjectResponse actionResponse = new
ShowUIObjectResponse(target.getPage().getId().toString(PortalObjectPath.CANONICAL_FORMAT));
- response = new ProcessorResponse(actionResponse);
- }
- return response;
+ //
+ return new ProcessorResponse(response);
}
catch(Exception e)
{
Modified:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/PresentationContentRendererContext.java
===================================================================
---
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/PresentationContentRendererContext.java 2007-11-18
23:19:13 UTC (rev 9016)
+++
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/PresentationContentRendererContext.java 2007-11-19
00:08:14 UTC (rev 9017)
@@ -102,7 +102,7 @@
public RenderInvocation createRenderInvocation(WindowNavigationalState
navigationalState)
{
- RenderInvocation invocation = new RenderInvocation(new
PresentationRenderContext(presentationContext, uiwindow, navigationalState));
+ RenderInvocation invocation = new RenderInvocation(new
PresentationRenderContext(uiwindow, navigationalState, presentationContext));
invocation.setRequestContext(new PresentationRequestContext(presentationContext));
invocation.setWindowContext(new WindowContextImpl(window));
invocation.setPortalContext(new PresentationPortalContext());
Added:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationActionContext.java
===================================================================
---
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationActionContext.java
(rev 0)
+++
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationActionContext.java 2007-11-19
00:08:14 UTC (rev 9017)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.presentation.server.content.portlet;
+
+import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.client.PresentationContext;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PresentationActionContext extends PresentationPortletInvocationContext
implements ActionContext
+{
+
+ /** . */
+ private final StateString interactionState;
+
+ /** . */
+ private final PortletParameters form;
+
+ public PresentationActionContext(
+ UIWindow uiwindow,
+ WindowNavigationalState navigationalState,
+ PresentationContext presentationContext,
+ StateString interactionState,
+ PortletParameters form)
+ {
+ super(uiwindow, navigationalState, presentationContext);
+
+ //
+ this.interactionState = interactionState;
+ this.form = form;
+ }
+
+ public String getCharacterEncoding()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public int getContentLength()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public BufferedReader getReader() throws IOException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public InputStream getInputStream() throws IOException, IllegalStateException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public String getContentType()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public StateString getInteractionState()
+ {
+ return interactionState;
+ }
+
+ public PortletParameters getForm()
+ {
+ return form;
+ }
+}
Added:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java
===================================================================
---
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java
(rev 0)
+++
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java 2007-11-19
00:08:14 UTC (rev 9017)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.presentation.server.content.portlet;
+
+import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.common.util.MediaType;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.PortletRequestEncoder;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.client.PresentationContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PresentationPortletInvocationContext extends AbstractInvocationContext
implements PortletInvocationContext
+{
+
+ /** . */
+ private static final MarkupInfo markupInfo = new MarkupInfo(MediaType.HTML,
"UTF-8");
+
+ /** . */
+ private final UIWindow uiwindow;
+
+ /** . */
+ private final WindowNavigationalState navigationalState;
+
+ /** . */
+ private final PresentationContext presentationContext;
+
+ public PresentationPortletInvocationContext(
+ UIWindow uiwindow,
+ WindowNavigationalState navigationalState,
+ PresentationContext presentationContext)
+ {
+ this.uiwindow = uiwindow;
+ this.navigationalState = navigationalState;
+ this.presentationContext = presentationContext;
+
+ //
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState.getContentState();
+ }
+
+ public Mode getMode()
+ {
+ return navigationalState.getMode();
+ }
+
+ public WindowState getWindowState()
+ {
+ return navigationalState.getWindowState();
+ }
+
+ public MarkupInfo getMarkupInfo()
+ {
+ return markupInfo; //To change body of implemented methods use File | Settings |
File Templates.
+ }
+
+ public String encodeResourceURL(String url) throws IllegalArgumentException
+ {
+ return "todo";
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ PortletRequestEncoder encoder = new PortletRequestEncoder();
+ encoder.encode(portletURL);
+ GetActivation get = new GetActivation(uiwindow.getId(),
encoder.getQueryParameters());
+ return presentationContext.render(get);
+ }
+}
Modified:
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationRenderContext.java
===================================================================
---
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationRenderContext.java 2007-11-18
23:19:13 UTC (rev 9016)
+++
branches/UIServer/core-uiserver/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationRenderContext.java 2007-11-19
00:08:14 UTC (rev 9017)
@@ -23,87 +23,18 @@
package org.jboss.portal.core.presentation.server.content.portlet;
import org.jboss.portal.portlet.spi.RenderContext;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletURL;
-import org.jboss.portal.portlet.impl.PortletRequestEncoder;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.client.PresentationContext;
-import org.jboss.portal.presentation.protocol.GetActivation;
-import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.common.util.MediaType;
-import org.jboss.portal.common.invocation.AbstractInvocationContext;
-import org.jboss.portal.common.invocation.resolver.MapAttributeResolver;
-import java.util.HashMap;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PresentationRenderContext extends AbstractInvocationContext implements
RenderContext
+public class PresentationRenderContext extends PresentationPortletInvocationContext
implements RenderContext
{
-
- /** . */
- private static final MarkupInfo markupInfo = new MarkupInfo(MediaType.HTML,
"UTF-8");
-
- /** . */
- private final PresentationContext presentationContext;
-
- /** . */
- private final UIWindow uiwindow;
-
- /** . */
- private final WindowNavigationalState navigationalState;
-
-
- public PresentationRenderContext(PresentationContext presentationContext, UIWindow
uiwindow, WindowNavigationalState navigationalState)
+ public PresentationRenderContext(UIWindow uiwindow, WindowNavigationalState
navigationalState, PresentationContext presentationContext)
{
- this.presentationContext = presentationContext;
- this.uiwindow = uiwindow;
- this.navigationalState = navigationalState;
-
- //
- addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.PRINCIPAL_SCOPE, new MapAttributeResolver());
- addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, new
MapAttributeResolver());
- addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ super(uiwindow, navigationalState, presentationContext);
}
-
- public StateString getNavigationalState()
- {
- return navigationalState.getContentState();
- }
-
- public Mode getMode()
- {
- return navigationalState.getMode();
- }
-
- public WindowState getWindowState()
- {
- return navigationalState.getWindowState();
- }
-
- public MarkupInfo getMarkupInfo()
- {
- return markupInfo;
- }
-
- public String encodeResourceURL(String url) throws IllegalArgumentException
- {
- return "todo";
- }
-
- public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
- {
- PortletRequestEncoder encoder = new PortletRequestEncoder();
- encoder.encode(portletURL);
- GetActivation get = new GetActivation(uiwindow.getId(),
encoder.getQueryParameters());
- return presentationContext.render(get);
- }
}
Modified:
branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml
===================================================================
---
branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml 2007-11-18
23:19:13 UTC (rev 9016)
+++
branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml 2007-11-19
00:08:14 UTC (rev 9017)
@@ -75,11 +75,11 @@
<depends>portal:service=InterceptorStackFactory,type=Command</depends>
<depends>portal:container=Instance</depends>
<depends>portal:service=PortalAuthorizationManagerFactory</depends>
- <depends>portal:service=CustomizationManager</depends>
<depends>portal:service=ContentProviderRegistry</depends>
<depends>portal:service=ResponseHandler,type=Selector</depends>
<depends>portal:service=ControlPolicy,type=Page</depends>
<depends optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
+ <depends optional-attribute-name="CustomizationManager"
proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
<mbean
code="org.jboss.portal.core.presentation.model.ModelLoaderImpl"