[portal-commits] JBoss Portal SVN: r9006 - in branches/JBoss_Portal_Branch_2_6: core/src/main/org/jboss/portal/core/impl/model/content/generic and 4 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Sun Nov 18 09:47:08 EST 2007


Author: julien at jboss.com
Date: 2007-11-18 09:47:07 -0500 (Sun, 18 Nov 2007)
New Revision: 9006

Added:
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
Modified:
   branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
   branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
Log:
- introduced ContentRendererContext to allow the content framework to be reused without the whole controller command pipeline

Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -26,25 +26,22 @@
 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.SecurityErrorResponse;
 import org.jboss.portal.core.controller.command.response.UnavailableResourceResponse;
-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.instance.InstancePermission;
 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.command.render.RenderWindowCommand;
+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.content.ContentRenderer;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
 import org.jboss.portal.core.model.portal.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;
@@ -154,26 +151,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(window.getInitialWindowState(), window.getInitialMode(), null);
-         context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey, windowNS);
+         rendererContext.setNavigationalState(windowNS);
       }
 
       //
@@ -182,7 +187,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)
@@ -202,13 +207,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;
@@ -247,7 +246,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/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -24,8 +24,6 @@
 
 import org.jboss.portal.Mode;
 import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.common.invocation.AttributeResolver;
-import org.jboss.portal.core.controller.ControllerContext;
 import org.jboss.portal.core.impl.model.content.InternalContentProvider;
 import org.jboss.portal.core.model.content.Content;
 import org.jboss.portal.core.model.content.ContentType;
@@ -37,11 +35,10 @@
 import org.jboss.portal.core.model.instance.InstanceContainer;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 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.command.response.MarkupResponse;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
 import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
-import org.jboss.portal.core.navstate.NavigationalStateKey;
 import org.jboss.portal.portlet.PortletParametersStateString;
 
 import java.util.Iterator;
@@ -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, window);
+         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/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -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/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -25,21 +25,28 @@
 import org.jboss.portal.core.controller.ControllerContext;
 import org.jboss.portal.core.controller.ControllerException;
 import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
 import org.jboss.portal.core.controller.command.info.CommandInfo;
 import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
 import org.jboss.portal.core.model.content.ContentType;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
 import org.jboss.portal.core.model.portal.command.WindowCommand;
 import org.jboss.portal.core.model.portal.content.ContentRenderer;
 import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
 import org.jboss.portal.core.model.portal.control.page.PageControlContext;
+import org.jboss.portal.core.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 at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
-public class RenderWindowCommand extends WindowCommand
+public class RenderWindowCommand extends WindowCommand implements ContentRendererContext
 {
 
    /** . */
@@ -95,4 +102,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/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -22,13 +22,11 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal.content;
 
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
-
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
 public interface ContentRenderer
 {
-   WindowRendition renderWindow(RenderWindowCommand cmd);
+   WindowRendition renderWindow(ContentRendererContext rendererContext);
 }

Added: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java	                        (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererContext.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -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 at 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/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java	2007-11-18 13:34:30 UTC (rev 9005)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java	2007-11-18 14:47:07 UTC (rev 9006)
@@ -27,8 +27,8 @@
 import org.jboss.portal.core.impl.model.content.generic.InternalGenericContentProvider;
 import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
 import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.command.render.RenderWindowCommand;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.content.ContentRendererContext;
 
 /**
  * @author <a href="mailto:julien at 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
       {




More information about the portal-commits mailing list