Author: julien(a)jboss.com
Date: 2007-11-18 12:12:22 -0500 (Sun, 18 Nov 2007)
New Revision: 9009
Added:
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
Modified:
branches/UIServer/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
branches/UIServer/uiserver/build.xml
Log:
port the content renderer framework improvement from 2.6
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -26,24 +26,21 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.core.aspects.portlet.AjaxInterceptor;
-import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
import org.jboss.portal.core.controller.command.response.SecurityErrorResponse;
-import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
+import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
@@ -138,26 +135,34 @@
/**
* Returns the portlet instance to render view mode.
*
- * @param command
+ * @param rendererContext
* @return the portlet instance for the view mode
*/
- protected abstract Instance getPortletInstance(RenderWindowCommand command);
+ protected abstract Instance getPortletInstance(ContentRendererContext
rendererContext);
- public WindowRendition renderWindow(RenderWindowCommand cmd)
+ public WindowRendition renderWindow(ContentRendererContext rendererContext)
{
- Window window = cmd.getWindow();
- Portal portal = cmd.getPortal();
- ControllerContext context = cmd.getControllerContext();
+ Window window = rendererContext.getWindow();
- PortalObjectId windowId = window.getId();
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, windowId);
- WindowNavigationalState windowNS =
(WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
nsKey);
+ // Get the parent portal
+ Portal portal = null;
+ for (PortalObject current = window;current != null;current = current.getParent())
+ {
+ if (current.getType() == PortalObject.TYPE_PORTAL)
+ {
+ portal = (Portal)current;
+ break;
+ }
+ }
//
+ WindowNavigationalState windowNS = rendererContext.getNavigationalState();
+
+ //
if (windowNS == null)
{
windowNS = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, null);
- context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey,
windowNS);
+ rendererContext.setNavigationalState(windowNS);
}
//
@@ -166,7 +171,7 @@
WindowState windowState = windowNS.getWindowState();
// Obtain instance
- Instance instance = getPortletInstance(cmd);
+ Instance instance = getPortletInstance(rendererContext);
// No instance means we can't continue
if (instance == null)
@@ -186,13 +191,7 @@
}
// Create invocation
- RenderInvocation invocation = PortletInvocationFactory.createRender(
- context,
- mode,
- windowState,
- windowNS.getContentState(),
- window,
- portal);
+ RenderInvocation invocation = rendererContext.createRenderInvocation(new
WindowNavigationalState(windowState, mode, windowNS.getContentState()));
//
List supportedWindowStates = Collections.EMPTY_LIST;
@@ -231,7 +230,7 @@
}
// Remove edit mode if the user is not logged it
- if
(context.getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() ==
null)
+ if (rendererContext.getUser() == null)
{
supportedModes.remove(Mode.EDIT);
}
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -22,6 +22,9 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.content.generic;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.impl.model.content.InternalContentProvider;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.ContentType;
@@ -31,18 +34,12 @@
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.impl.model.content.InternalContentProvider;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.invocation.AttributeResolver;
import java.util.Iterator;
import java.util.Map;
@@ -129,16 +126,14 @@
return new GenericContent(state);
}
- protected Instance getPortletInstance(RenderWindowCommand command)
+ protected Instance getPortletInstance(ContentRendererContext rendererContext)
{
String id = contentPortlet.getPortletName(Mode.VIEW);
//
if (id != null)
{
- ControllerContext context = command.getControllerContext();
- InstanceContainer container = context.getController().getInstanceContainer();
- return container.getDefinition(id);
+ return instanceContainer.getDefinition(id);
}
else
{
@@ -154,10 +149,9 @@
{
}
- public WindowRendition renderWindow(RenderWindowCommand cmd)
+ public WindowRendition renderWindow(ContentRendererContext rendererContext)
{
- ControllerContext context = cmd.getControllerContext();
- Window window = cmd.getWindow();
+ Window window = rendererContext.getWindow();
PortalObjectId windowId = window.getId();
// No content
@@ -168,11 +162,9 @@
}
//
- AttributeResolver nsResolver =
context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
// Initialize the navigational state with the URI when needed
- NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, windowId);
- WindowNavigationalState navigationalState =
(WindowNavigationalState)nsResolver.getAttribute(nsKey);
+ WindowNavigationalState navigationalState =
rendererContext.getNavigationalState();
//
// boolean update = true;
@@ -203,11 +195,11 @@
state.setValue("uri", uri);
//
- WindowNavigationalState.setState(nsResolver, nsKey, state);
+
rendererContext.setNavigationalState(WindowNavigationalState.bilto(navigationalState,
null, null, state));
}
//
- WindowRendition rendition = super.renderWindow(cmd);
+ WindowRendition rendition = super.renderWindow(rendererContext);
//
if (rendition != null && rendition.getControllerResponse() instanceof
MarkupResponse && !getDecorateContent())
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -28,7 +28,6 @@
import org.jboss.portal.common.i18n.ResourceBundleManager;
import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
import org.jboss.portal.common.util.EmptyResourceBundle;
-import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.impl.model.content.InternalContentProvider;
import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.core.model.content.Content;
@@ -40,7 +39,7 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
import org.jboss.portal.identity.User;
/**
@@ -179,15 +178,13 @@
// ContentRenderer implementation
***********************************************************************************
- protected Instance getPortletInstance(RenderWindowCommand command)
+ protected Instance getPortletInstance(ContentRendererContext rendererContext)
{
- ControllerContext context = command.getControllerContext();
-
// The window
- Window window = command.getWindow();
+ Window window = rendererContext.getWindow();
// We need the user id
- User user = context.getUser();
+ User user = rendererContext.getUser();
// Get instance
return customizationManager.getInstance(window, user);
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -25,21 +25,28 @@
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.control.page.PageControlContext;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
+import org.jboss.portal.core.navstate.NavigationalStateKey;
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class RenderWindowCommand extends WindowCommand
+public class RenderWindowCommand extends WindowCommand implements ContentRendererContext
{
/** . */
@@ -98,4 +105,34 @@
//
return null;
}
+
+ public WindowNavigationalState getNavigationalState()
+ {
+ AttributeResolver nsResolver =
context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ return (WindowNavigationalState)nsResolver.getAttribute(nsKey);
+ }
+
+ public void setNavigationalState(WindowNavigationalState navigationalState)
+ {
+ AttributeResolver nsResolver =
context.getAttributeResolver(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE);
+ NavigationalStateKey nsKey = new
NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ nsResolver.setAttribute(nsKey, navigationalState);
+ }
+
+ public User getUser()
+ {
+ return context.getUser();
+ }
+
+ public RenderInvocation createRenderInvocation(WindowNavigationalState
navigationalState)
+ {
+ return PortletInvocationFactory.createRender(
+ context,
+ navigationalState.getMode(),
+ navigationalState.getWindowState(),
+ navigationalState.getContentState(),
+ window,
+ portal);
+ }
}
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -22,14 +22,11 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.content;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
-import org.jboss.portal.core.model.portal.content.WindowRendition;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public interface ContentRenderer
{
- WindowRendition renderWindow(RenderWindowCommand cmd);
+ WindowRendition renderWindow(ContentRendererContext rendererContext);
}
Copied:
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
(from rev 9006,
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java)
===================================================================
---
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
(rev 0)
+++
branches/UIServer/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.model.portal.content;
+
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+
+/**
+ * Abstract the services provided to a content renderer for the render phase.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentRendererContext
+{
+
+ Window getWindow();
+
+ WindowNavigationalState getNavigationalState();
+
+ void setNavigationalState(WindowNavigationalState navigationalState);
+
+ User getUser();
+
+ RenderInvocation createRenderInvocation(WindowNavigationalState navigationalState);
+}
Modified:
branches/UIServer/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
===================================================================
---
branches/UIServer/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java 2007-11-18
15:13:49 UTC (rev 9008)
+++
branches/UIServer/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java 2007-11-18
17:12:22 UTC (rev 9009)
@@ -23,12 +23,12 @@
package org.jboss.portal.core.cms.content;
import org.jboss.portal.core.impl.model.content.generic.InternalGenericContentProvider;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.content.WindowRendition;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.cms.CMSObjectCommandFactory;
import org.jboss.portal.Mode;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -89,11 +89,11 @@
super.start();
}
- public WindowRendition renderWindow(RenderWindowCommand cmd)
+ public WindowRendition renderWindow(ContentRendererContext rendererContext)
{
try
{
- PortalObjectId windowId = cmd.getWindow().getId();
+ PortalObjectId windowId = rendererContext.getWindow().getId();
//
if (windowId.equals(targetWindowId))
@@ -102,7 +102,7 @@
}
//
- return super.renderWindow(cmd);
+ return super.renderWindow(rendererContext);
}
finally
{
Modified: branches/UIServer/uiserver/build.xml
===================================================================
--- branches/UIServer/uiserver/build.xml 2007-11-18 15:13:49 UTC (rev 9008)
+++ branches/UIServer/uiserver/build.xml 2007-11-18 17:12:22 UTC (rev 9009)
@@ -99,12 +99,11 @@
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
- <path refid="jboss.portlet-api.classpath"/>
- <path refid="jboss.portal-jems.classpath"/>
- <path refid="jboss.portal-common.classpath"/>
- <path refid="jboss.portal-server.classpath"/>
- <path refid="jboss.portal-web.classpath"/>
- <path refid="jboss.portal-core-uiserver.classpath"/>
+ <path refid="jboss.portlet-api.classpath"/>
+ <path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-common.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-web.classpath"/>
</path>
<!--+=======================================+-->