[portal-commits] JBoss Portal SVN: r6007 - in trunk: core/src/main/org/jboss/portal/core/cms and 17 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Mon Jan 15 18:11:11 EST 2007


Author: julien at jboss.com
Date: 2007-01-15 18:10:21 -0500 (Mon, 15 Jan 2007)
New Revision: 6007

Added:
   trunk/core/src/main/org/jboss/portal/core/cms/command/
   trunk/core/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java
   trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
   trunk/core/src/main/org/jboss/portal/core/cms/content/
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/content/
Removed:
   trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java
   trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java
   trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java
Modified:
   trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
   trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
   trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectURLFactory.java
   trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
   trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PageImpl.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java
   trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/Page.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/Window.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowActionCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java
   trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
   trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
   trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
   trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
   trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
   trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
   trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
   trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
   trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
Log:
JBPORTAL-1195 : Content framework for content integration at the window level

Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -41,11 +41,8 @@
 import org.jboss.portal.core.model.portal.command.WindowCommand;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 import org.jboss.portal.core.event.PortalEventListenerRegistry;
-import org.jboss.portal.core.model.instance.Instance;
 import org.jboss.portal.portlet.PortletParameters;
 import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
 import org.jboss.portal.portlet.StateString;
 
 import java.util.Map;
@@ -190,95 +187,80 @@
       if (cmd instanceof WindowCommand)
       {
          WindowCommand wc = (WindowCommand)cmd;
-
-         // Get the instance
-         Instance instance = wc.getInstance();
-         try
+         if (cmd instanceof InvokePortletWindowActionCommand)
          {
-            // Get the portlet
-            Portlet portlet = instance.getPortlet();
-            if (portlet != null && portlet.isRemote() == false)
-            {
-               if (cmd instanceof InvokePortletWindowActionCommand)
-               {
-                  InvokePortletWindowActionCommand iwac = (InvokePortletWindowActionCommand)wc;
+            InvokePortletWindowActionCommand iwac = (InvokePortletWindowActionCommand)wc;
 
-                  //
-                  PortletParameters formParams = iwac.getFormParameters();
+            //
+            PortletParameters formParams = iwac.getFormParameters();
 
-                  //
-                  PortletParameters interactionParams = null;
-                  if (iwac.getInteractionState() instanceof PortletParametersStateString)
-                  {
-                     interactionParams = ((PortletParametersStateString)iwac.getInteractionState()).getParameters();
-                  }
+            //
+            PortletParameters interactionParams = null;
+            if (iwac.getInteractionState() instanceof PortletParametersStateString)
+            {
+               interactionParams = ((PortletParametersStateString)iwac.getInteractionState()).getParameters();
+            }
 
-                  //
-                  Map params = null;
-                  if (interactionParams != null)
-                  {
-                     if (formParams != null)
-                     {
-                        params = new LazyParameterMap(interactionParams, formParams);
-                     }
-                     else
-                     {
-                        params = interactionParams;
-                     }
-                  }
-                  else
-                  {
-                     if (formParams != null)
-                     {
-                        params = formParams;
-                     }
-                     else
-                     {
-                        params = new PortletParameters();
-                     }
-                  }
-
-                  //
-                  WindowActionEvent action = new WindowActionEvent(node);
-                  action.setMode(iwac.getMode());
-                  action.setWindowState(iwac.getWindowState());
-                  action.setParameters(params);
-                  return action;
+            //
+            Map params;
+            if (interactionParams != null)
+            {
+               if (formParams != null)
+               {
+                  params = new LazyParameterMap(interactionParams, formParams);
                }
-               else if (cmd instanceof InvokePortletWindowRenderCommand)
+               else
                {
-                  InvokePortletWindowRenderCommand iwrc = (InvokePortletWindowRenderCommand)wc;
-                  StateString navigationalState = iwrc.getNavigationalState();
-
-                  //
-                  if (navigationalState != null)
-                  {
-                     Map params = null;
-                     if (navigationalState instanceof PortletParametersStateString)
-                     {
-                        params = ((PortletParametersStateString)navigationalState).getParameters();
-                     }
-
-                     //
-                     WindowRenderEvent render = new WindowRenderEvent(node);
-                     render.setMode(iwrc.getMode());
-                     render.setWindowState(iwrc.getWindowState());
-                     render.setParameters(params);
-                     return render;
-                  }
-                  else
-                  {
-                     WindowNavigationEvent navigation = new WindowNavigationEvent(node);
-                     navigation.setMode(iwrc.getMode());
-                     navigation.setWindowState(iwrc.getWindowState());
-                     return navigation;
-                  }
+                  params = interactionParams;
                }
             }
+            else
+            {
+               if (formParams != null)
+               {
+                  params = formParams;
+               }
+               else
+               {
+                  params = new PortletParameters();
+               }
+            }
+
+            //
+            WindowActionEvent action = new WindowActionEvent(node);
+            action.setMode(iwac.getMode());
+            action.setWindowState(iwac.getWindowState());
+            action.setParameters(params);
+            return action;
          }
-         catch (PortletInvokerException ignore)
+         else if (cmd instanceof InvokePortletWindowRenderCommand)
          {
+            InvokePortletWindowRenderCommand iwrc = (InvokePortletWindowRenderCommand)wc;
+            StateString navigationalState = iwrc.getNavigationalState();
 
+            //
+            if (navigationalState != null)
+            {
+               Map params = null;
+               if (navigationalState instanceof PortletParametersStateString)
+               {
+                  params = ((PortletParametersStateString)navigationalState).getParameters();
+               }
+
+               //
+               WindowRenderEvent render = new WindowRenderEvent(node);
+               render.setMode(iwrc.getMode());
+               render.setWindowState(iwrc.getWindowState());
+               render.setParameters(params);
+               return render;
+            }
+            else
+            {
+               WindowNavigationEvent navigation = new WindowNavigationEvent(node);
+               navigation.setMode(iwrc.getMode());
+               navigation.setWindowState(iwrc.getWindowState());
+               return navigation;
+            }
          }
       }
       return null;

Modified: trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -32,6 +32,7 @@
 import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
 import org.jboss.portal.portlet.PortletParametersStateString;
 import org.jboss.portal.server.ServerInvocation;
 
@@ -96,20 +97,6 @@
    {
       try
       {
-/*
-         Command itemExistsCMD = CMSService.getCommandFactory().createItemExistsCommand(portalRequestPath + "/" + invocation.getRequest().getLocale().getLanguage());
-         Boolean bExists = (Boolean) CMSService.execute(itemExistsCMD);
-         Command getCMD;
-
-         if(bExists.booleanValue())
-         {
-            getCMD = CMSService.getCommandFactory().createFileGetCommand(portalRequestPath, invocation.getRequest().getLocale());
-         }
-         else
-         {
-            getCMD = CMSService.getCommandFactory().createFileGetCommand(portalRequestPath, new Locale(CMSService.getDefaultLocale()));
-         }
-*/
          Command getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, invocation.getRequest().getLocale());
          File file = (File)CMSService.execute(getCMD);
          if (file == null)

Modified: trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectURLFactory.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectURLFactory.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -24,6 +24,7 @@
 
 import org.jboss.portal.core.controller.ControllerCommand;
 import org.jboss.portal.core.controller.command.mapper.URLFactoryDelegate;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
 import org.jboss.portal.server.AbstractServerURL;
 import org.jboss.portal.server.ServerInvocation;
 import org.jboss.portal.server.ServerURL;

Deleted: trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,104 +0,0 @@
-/******************************************************************************
- * 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.cms;
-
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.portal.cms.CMS;
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.model.Content;
-import org.jboss.portal.cms.model.File;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
-import org.jboss.portal.core.controller.command.response.StreamContentResponse;
-import org.jboss.portal.server.ServerInvocation;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.io.InputStream;
-import java.util.Locale;
-
-/**
- * Renders content from the cms.
- *
- * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
- */
-public class StreamContentCommand extends ControllerCommand
-{
-
-   private static final CommandInfo info = new ViewCommandInfo(false, null);
-
-   private String path;
-
-   public StreamContentCommand(String path)
-      throws IllegalArgumentException
-   {
-      this.path = path;
-   }
-
-   public String getPath()
-   {
-      return path;
-   }
-
-   public CommandInfo getInfo()
-   {
-      return info;
-   }
-
-   public Object execute() throws InvocationException, ControllerException
-   {
-      try
-      {
-         MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
-         CMS CMSService = (CMS)MBeanProxy.get(CMS.class, new ObjectName("portal:service=CMS"), mbeanServer);
-         ServerInvocation serverInvocation = getControllerContext().getServerInvocation();
-         Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path, serverInvocation.getRequest().getLocale());
-         File file = (File)CMSService.execute(getCMD);
-         if (file == null)
-         {
-            getCMD = CMSService.getCommandFactory().createFileGetCommand(path, new Locale(CMSService.getDefaultLocale()));
-            file = (File)CMSService.execute(getCMD);
-         }
-         Content content = file.getContent();
-         String mimeType = content.getMimeType();
-         InputStream inputStream = content.getStream();
-         return new StreamContentResponse(mimeType, inputStream);
-      }
-      catch (Exception e)
-      {
-//         try
-//         {
-//            resp.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
-//         }
-//         catch(IOException e1)
-//         {
-//            log.error("An error occured when wanting to stream the command", e);
-//         }
-         throw new ControllerException(e);
-      }
-   }
-}
\ No newline at end of file

Added: trunk/core/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/cms/command/RenderCMSWindowCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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.cms.command;
+
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.command.RenderPortletWindowCommand;
+import org.jboss.portal.core.cms.content.CMSContent;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.theme.page.WindowResult;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RenderCMSWindowCommand extends RenderPortletWindowCommand
+{
+
+   public RenderCMSWindowCommand(PortalObjectId windowId)
+      throws IllegalArgumentException
+   {
+      super(windowId);
+   }
+
+   protected Instance findInstance()
+   {
+      PortalObjectId windowId = window.getId();
+
+      //
+      CMSContent content = (CMSContent)window.getContent();
+      String uri = content.getURI();
+
+      // Initialize the navigational state with the URI when needed
+      PortletParametersStateString navigationalState = (PortletParametersStateString)getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId);
+      if (navigationalState == null)
+      {
+         navigationalState = new PortletParametersStateString();
+         navigationalState.setValue("path", uri);
+         setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
+      }
+
+      // Make that configurable
+      InstanceContainer container = getControllerContext().getController().getInstanceContainer();
+      return container.getDefinition("CMSPortletInstance");
+   }
+
+
+   public Object execute() throws ControllerException
+   {
+      Object o = super.execute();
+
+      //
+      if (o instanceof WindowResult)
+      {
+         WindowResult result = (WindowResult)o;
+
+         //
+         Map props = new HashMap(result.getWindowProperties());
+         props.put("theme.windowRendererId", "emptyRenderer");
+         props.put("theme.decorationRendererId", "emptyRenderer");
+         props.put("theme.portletRendererId", "emptyRenderer");
+
+         //
+         result.setWindowProperties(props);
+      }
+
+      //
+      return o;
+   }
+}

Copied: trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/StreamContentCommand.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -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.cms.command;
+
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.command.response.StreamContentResponse;
+import org.jboss.portal.server.ServerInvocation;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.io.InputStream;
+import java.util.Locale;
+
+/**
+ * Renders content from the cms.
+ *
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
+public class StreamContentCommand extends ControllerCommand
+{
+
+   private static final CommandInfo info = new ViewCommandInfo(false, null);
+
+   private String path;
+
+   public StreamContentCommand(String path)
+      throws IllegalArgumentException
+   {
+      this.path = path;
+   }
+
+   public String getPath()
+   {
+      return path;
+   }
+
+   public CommandInfo getInfo()
+   {
+      return info;
+   }
+
+   public Object execute() throws InvocationException, ControllerException
+   {
+      try
+      {
+         MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+         CMS CMSService = (CMS)MBeanProxy.get(CMS.class, new ObjectName("portal:service=CMS"), mbeanServer);
+         ServerInvocation serverInvocation = getControllerContext().getServerInvocation();
+         Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path, serverInvocation.getRequest().getLocale());
+         File file = (File)CMSService.execute(getCMD);
+         if (file == null)
+         {
+            getCMD = CMSService.getCommandFactory().createFileGetCommand(path, new Locale(CMSService.getDefaultLocale()));
+            file = (File)CMSService.execute(getCMD);
+         }
+         Content content = file.getContent();
+         String mimeType = content.getMimeType();
+         InputStream inputStream = content.getStream();
+         return new StreamContentResponse(mimeType, inputStream);
+      }
+      catch (Exception e)
+      {
+//         try
+//         {
+//            resp.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
+//         }
+//         catch(IOException e1)
+//         {
+//            log.error("An error occured when wanting to stream the command", e);
+//         }
+         throw new ControllerException(e);
+      }
+   }
+}
\ No newline at end of file


Property changes on: trunk/core/src/main/org/jboss/portal/core/cms/command/StreamContentCommand.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -27,10 +27,13 @@
 import org.jboss.portal.common.metadata.MetaData;
 import org.jboss.portal.common.util.Tools;
 import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.metadata.PortalObjectMetaData;
+import org.jboss.portal.core.model.portal.metadata.PortalObjectMetaData;
+import org.jboss.portal.core.model.portal.metadata.BuildContext;
 import org.jboss.portal.core.model.portal.PortalObject;
 import org.jboss.portal.core.model.portal.PortalObjectContainer;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
 import org.jboss.portal.server.deployment.PortalWebApp;
 import org.jboss.portal.server.deployment.jboss.Deployment;
 import org.w3c.dom.Document;
@@ -155,7 +158,7 @@
             }
             if (metaDataElt != null)
             {
-               metaData = PortalObjectMetaData.buildMetaData(metaDataElt);
+               metaData = PortalObjectMetaData.buildMetaData(factory.contentHandlerRegistry, metaDataElt);
             }
             else
             {
@@ -171,22 +174,16 @@
          }
 
          // Resolve against ref in the same deployment
-         PortalObjectMetaData.BuildContext portalObjectBuildContext = new PortalObjectMetaData.BuildContext()
+         BuildContext portalObjectBuildContext = new BuildContext()
          {
-            public String resolveParentRef(String ref)
-            {
-               return ref;
-            }
-
-            public String resolveInstanceRef(String ref)
-            {
-               return ref;
-            }
-
             public PortalObjectContainer getContainer()
             {
                return factory.portalObjectContainer;
             }
+            public ContentHandler getHandler(ContentType contentType)
+            {
+               return factory.contentHandlerRegistry.getHandler(contentType);
+            }
          };
 
          // Create all objects
@@ -221,7 +218,7 @@
                   if (create)
                   {
                      log.debug("Building portal object");
-                     PortalObject po = portalObjectMD.create(parent, portalObjectBuildContext);
+                     PortalObject po = portalObjectMD.create(portalObjectBuildContext, parent);
                      unit.ref = po.getId();
                   }
                }

Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -25,6 +25,7 @@
 import org.jboss.deployment.DeploymentException;
 import org.jboss.portal.common.transaction.TransactionManagerProvider;
 import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
 import org.jboss.portal.server.deployment.PortalWebApp;
 import org.jboss.portal.server.deployment.jboss.AbstractDeploymentFactory;
 import org.jboss.portal.server.deployment.jboss.Deployment;
@@ -50,6 +51,9 @@
    /** . */
    protected PortalObjectContainer portalObjectContainer;
 
+   /** . */
+   protected ContentHandlerRegistry contentHandlerRegistry;
+
    public boolean acceptFile(URL url)
    {
       String urlAsFile = url.getFile();
@@ -79,4 +83,14 @@
    {
       this.portalObjectContainer = portalObjectContainer;
    }
+
+   public ContentHandlerRegistry getContentHandlerRegistry()
+   {
+      return contentHandlerRegistry;
+   }
+
+   public void setContentHandlerRegistry(ContentHandlerRegistry contentHandlerRegistry)
+   {
+      this.contentHandlerRegistry = contentHandlerRegistry;
+   }
 }

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -34,6 +34,8 @@
 import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
 import org.jboss.portal.core.model.portal.PortalContainer;
 import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.portlet.content.PortletContent;
+import org.jboss.portal.core.model.content.Content;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
 import org.jboss.portal.identity.UserModule;
@@ -162,7 +164,8 @@
       }
 
       //
-      String instanceId = window.getInstanceRef();
+      Content content = window.getContent();
+      String instanceId = ((PortletContent)content).getInstanceRef();
       if (instanceId == null)
       {
          return null;

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -26,7 +26,10 @@
 import org.jboss.portal.core.model.portal.PortalObjectContainer;
 import org.jboss.portal.core.model.portal.PortalObjectPermission;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
 import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
 import org.jboss.portal.jems.as.system.AbstractJBossService;
 import org.jboss.portal.security.PortalPermission;
 import org.jboss.portal.security.PortalPermissionCollection;
@@ -41,13 +44,15 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
 public abstract class AbstractPortalObjectContainer extends AbstractJBossService
-   implements PortalObjectContainer, PermissionFactory, AuthorizationDomain, DomainConfigurator, PermissionRepository
+   implements PortalObjectContainer, PermissionFactory, AuthorizationDomain, DomainConfigurator, PermissionRepository, ContentHandlerRegistry
 {
 
    /** . */
@@ -56,6 +61,9 @@
    /** . */
    private InstanceContainer instanceContainer;
 
+   /** . */
+   private volatile Map contentHandlerRegistry;
+
    public InstanceContainer getInstanceContainer()
    {
       return instanceContainer;
@@ -64,8 +72,58 @@
    public void setInstanceContainer(InstanceContainer instanceContainer)
    {
       this.instanceContainer = instanceContainer;
+      this.contentHandlerRegistry = new HashMap();
    }
 
+   public void registerHandler(ContentType contentType, ContentHandler handler) throws IllegalArgumentException
+   {
+      if (contentType == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      if (handler == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      synchronized(this)
+      {
+         if (contentHandlerRegistry.containsKey(contentType))
+         {
+            throw new IllegalArgumentException("Content type " + contentType + " is already registered");
+         }
+
+         //
+         Map tmp = new HashMap(contentHandlerRegistry);
+         tmp.put(contentType, handler);
+         contentHandlerRegistry = tmp;
+      }
+   }
+
+   public ContentHandler getHandler(ContentType contentType)
+   {
+      return (ContentHandler)contentHandlerRegistry.get(contentType);
+   }
+
+   public void unregisterHandler(ContentType contentType)
+   {
+      if (contentType == null)
+      {
+         throw new IllegalArgumentException();
+      }
+      synchronized(this)
+      {
+         if (contentHandlerRegistry.containsKey(contentType) == false)
+         {
+            throw new IllegalArgumentException("Content type " + contentType + " is not registered");
+         }
+
+         //
+         Map tmp = new HashMap(contentHandlerRegistry);
+         tmp.remove(contentType);
+         contentHandlerRegistry = tmp;
+      }
+   }
+
    public PortalObject getRootObject()
    {
       return getObject(rootId);
@@ -180,22 +238,38 @@
       }
    }
 
-   public interface Context
+   public class Context
    {
       /**
        */
-      PortalObjectContainer getContainer();
+      public PortalObjectContainer getContainer()
+      {
+         return AbstractPortalObjectContainer.this;
+      }
 
       /**
        */
-      void destroyChild(ObjectNode node);
+      public void destroyChild(ObjectNode node)
+      {
+      }
 
       /**
        */
-      void createChild(ObjectNode node);
+      public void createChild(ObjectNode node)
+      {
+      }
 
       /**
        */
-      void updated(ObjectNode node);
+      public void updated(ObjectNode node)
+      {
+      }
+
+      /**
+       */
+      public ContentHandler getContentHandler(ContentType contentType)
+      {
+         return (ContentHandler)contentHandlerRegistry.get(contentType);
+      }
    }
 }

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -145,6 +145,13 @@
       //
       children.put(name, childNode);
       childNode.parent = this;
+
+      // Contextualize
+      if (childObject instanceof ContextObject)
+      {
+         ContextObject co = (ContextObject)childObject;
+         co.setContext(context);
+      }
    }
 
    /** Destroy the association. */

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PageImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PageImpl.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PageImpl.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -27,6 +27,7 @@
 import org.jboss.portal.core.model.portal.Portal;
 import org.jboss.portal.core.model.portal.PortalObject;
 import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.ContentType;
 
 import java.util.HashMap;
 
@@ -84,9 +85,9 @@
       return null;
    }
 
-   public Window createWindow(String name) throws DuplicatePortalObjectException
+   public Window createWindow(String name, ContentType contentType) throws DuplicatePortalObjectException, IllegalArgumentException
    {
-      WindowImpl window = new WindowImpl(false);
+      WindowImpl window = new WindowImpl(contentType);
       addChild(name, window);
       return window;
    }

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -28,7 +28,6 @@
 import org.hibernate.Criteria;
 import org.hibernate.criterion.Restrictions;
 import org.jboss.logging.Logger;
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
 import org.jboss.portal.jems.hibernate.ObjectContextualizer;
 import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -82,11 +81,6 @@
    {
       ctx = new Context()
       {
-         public PortalObjectContainer getContainer()
-         {
-            return PersistentPortalObjectContainer.this;
-         }
-
          public void destroyChild(ObjectNode node)
          {
             Session session = sessionFactory.getCurrentSession();

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -437,3 +437,5 @@
       return dashboardContext;
    }
 }
+
+

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -45,25 +45,7 @@
       super.createService();
 
       //
-      ctx = new Context()
-      {
-         public PortalObjectContainer getContainer()
-         {
-            return TransientPortalObjectContainer.this;
-         }
-
-         public void destroyChild(ObjectNode node)
-         {
-         }
-
-         public void createChild(ObjectNode node)
-         {
-         }
-
-         public void updated(ObjectNode node)
-         {
-         }
-      };
+      ctx = new Context();
    }
 
    public boolean createRootObject()

Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -24,9 +24,11 @@
 
 import org.jboss.portal.core.model.portal.PortalObject;
 import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.jems.hibernate.ContextObject;
 
 import java.util.HashMap;
 
@@ -34,25 +36,54 @@
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
-public class WindowImpl extends PortalObjectImpl implements Window
+public class WindowImpl extends PortalObjectImpl implements Window, ContextObject
 {
 
+   public static final String blah = "bluh";
+
    // Persistent state
    protected String instanceRef;
 
+   // Runtime fields
+   protected AbstractPortalObjectContainer.Context context;
+   protected ContentType contentType;
+   protected ContentStateImpl contentState;
+
    public WindowImpl()
    {
-      this(true);
+      super(true);
+
+      //
+      this.instanceRef = null;
+      this.contentType = null;
    }
 
-   public WindowImpl(boolean hibernate)
+   public WindowImpl(ContentType contentType)
    {
-      super(hibernate);
+      super(false);
 
       //
       this.instanceRef = null;
+      this.contentType = contentType;
+
+      //
+      setDeclaredProperty(blah, contentType.toString());
    }
 
+   private ContentStateImpl getContentState()
+   {
+      if (contentState == null)
+      {
+         contentState = new ContentStateImpl();
+      }
+      return contentState;
+   }
+
+   public void setContext(Object context)
+   {
+      this.context = (AbstractPortalObjectContainer.Context)context;
+   }
+
    public String getInstanceRef()
    {
       return instanceRef;
@@ -60,13 +91,37 @@
 
    public void setInstanceRef(String instanceRef)
    {
-      if (Tools.safeEquals(this.instanceRef, instanceRef) == false)
+      this.instanceRef = instanceRef;
+   }
+
+   public Content getContent()
+   {
+      return getContentState().getContent();
+   }
+
+   public ContentType getContentType()
+   {
+      if (contentType == null)
       {
-         destroyRelatedCustomization();
+         String value = getDeclaredProperty(blah);
+         if (value == null)
+         {
+            // For legacy content we chose to treat no value as portlet
+            contentType = ContentType.PORTLET;
+         }
+         else
+         {
+            contentType = ContentType.create(value);
+         }
       }
-      this.instanceRef = instanceRef;
+      return contentType;
    }
 
+   public String getURI()
+   {
+      return instanceRef;
+   }
+
    public int getType()
    {
       return PortalObject.TYPE_WINDOW;
@@ -82,29 +137,72 @@
 
    protected void destroy()
    {
-      destroyRelatedCustomization();
+      // Destroy the associated content if it is necessary/possible
+      getContentState().destroy();
    }
 
    /**
-    * Destroy the associated customization if it is necessary/possible.
+    * Encapsulate content behavior for a window.
     */
-   private void destroyRelatedCustomization()
+   private class ContentStateImpl implements ContentState
    {
-      if (instanceRef != null)
+
+      /** . */
+      private final String contextId = getId().toString();
+
+      /** . */
+      private Content content;
+
+      public String getURI()
       {
-         AbstractPortalObjectContainer container = (AbstractPortalObjectContainer)getObjectNode().getContext().getContainer();
-         InstanceContainer instanceContainer = container.getInstanceContainer();
-         Instance instance = instanceContainer.getDefinition(instanceRef);
+         return instanceRef;
+      }
 
+      public void setURI(String uri)
+      {
+         instanceRef = uri;
+      }
+
+      public void setProperty(String name, String value)
+      {
+         setDeclaredProperty(name, value);
+      }
+
+      public String getProperty(String name)
+      {
+         return getDeclaredProperty(name);
+      }
+
+      private void destroy()
+      {
+         ContentHandler handler = getContentHandler();
+
          //
-         if (instance != null)
+         handler.destroyContent(contextId, this);
+      }
+
+      private Content getContent()
+      {
+         if (content == null)
          {
-            // That's how we manufacture dash board keys
-            String customizationId = getId().toString();
+            ContentHandler handler = getContentHandler();
 
-            // Destroy related instance customization
-            instance.destroyCustomization(customizationId);
+            //
+            if (handler != null)
+            {
+               String contextId = getId().toString();
+               content = handler.newContent(contextId, this);
+            }
          }
+         return content;
       }
+
+      private ContentHandler getContentHandler()
+      {
+         ContentType contentType = getContentType();
+
+         //
+         return context.getContentHandler(contentType);
+      }
    }
 }

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,92 +0,0 @@
-/******************************************************************************
- * 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.metadata;
-
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalContainer;
-import org.jboss.portal.common.util.XML;
-import org.w3c.dom.Element;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContextMetaData extends PortalObjectMetaData
-{
-   public PortalObject create(PortalObject parent, BuildContext buildContext) throws Exception
-   {
-      if (parent instanceof PortalContainer == false)
-      {
-         throw new IllegalArgumentException("Not a context");
-      }
-
-      //
-      PortalContainer container = ((PortalContainer)parent).createPortalContainer(getName());
-
-      //
-      configure(container, buildContext);
-
-      //
-      for (Iterator i = getChildren().values().iterator(); i.hasNext();)
-      {
-         PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)i.next();
-         portalObjectMD.create(container, buildContext);
-      }
-
-      //
-      return container;
-   }
-
-   /** Parse the following XML elements : context-name. */
-   public static ContextMetaData buildContextMetaData(Element contextElt) throws Exception
-   {
-      ContextMetaData contextMD = new ContextMetaData();
-
-      //
-      String contextName = XML.asString(XML.getUniqueChild(contextElt, "context-name", true));
-      if (contextName != null && contextName.length() > 0 && contextName.indexOf(".") < 0)
-      {
-         contextMD.setName(contextName);
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid context-name: '" + contextName
-            + "'. Must not be null, empty or contain a '.'");
-      }
-
-      //
-      List pageElts = XML.getChildren(contextElt, "portal");
-      for (int i = 0; i < pageElts.size(); i++)
-      {
-         Element portalElt = (Element)pageElts.get(i);
-         PortalMetaData pageMD = (PortalMetaData)PortalObjectMetaData.buildMetaData(portalElt);
-         contextMD.getChildren().put(pageMD.getName(), pageMD);
-      }
-
-      //
-      return contextMD;
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,115 +0,0 @@
-/******************************************************************************
- * 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.metadata;
-
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PageContainer;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.w3c.dom.Element;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PageMetaData extends PortalObjectMetaData
-{
-   public PageMetaData()
-   {
-   }
-
-   public PortalObject create(PortalObject parent, BuildContext buildContext) throws Exception
-   {
-      if (!(parent instanceof PageContainer))
-      {
-         throw new IllegalArgumentException("Cannot build page " + getName() + " because the parent it references is not a page container " + parent);
-      }
-
-      //
-      Page page = ((PageContainer)parent).createPage(getName());
-
-      //
-      configure(page, buildContext);
-
-      //
-      for (Iterator i = getChildren().values().iterator(); i.hasNext();)
-      {
-         PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)i.next();
-         portalObjectMD.create(page, buildContext);
-      }
-
-      return page;
-   }
-
-   public static PageMetaData buildPageMetaData(Element pageElt)
-   {
-      PageMetaData pageMD = new PageMetaData();
-
-      //
-      String pageName = XML.asString(XML.getUniqueChild(pageElt, "page-name", true));
-      pageMD.setName(pageName);
-
-      // Add the contained getWindows
-      List windowElts = XML.getChildren(pageElt, "window");
-      for (int j = 0; j < windowElts.size(); j++)
-      {
-         Element windowElt = (Element)windowElts.get(j);
-         try
-         {
-            WindowMetaData windowMD = (WindowMetaData)PortalObjectMetaData.buildMetaData(windowElt);
-            pageMD.getChildren().put(windowMD.getName(), windowMD);
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();
-         }
-      }
-
-      // Add the contained pages
-      List pageElts = XML.getChildren(pageElt, "page");
-      for (int j = 0; j < pageElts.size(); j++)
-      {
-         Element childPageElt = (Element)pageElts.get(j);
-         try
-         {
-            PageMetaData childPageMD = (PageMetaData)PortalObjectMetaData.buildMetaData(childPageElt);
-            pageMD.getChildren().put(childPageMD.getName(), childPageMD);
-         }
-         catch (Exception e)
-         {
-            e.printStackTrace();
-         }
-      }
-
-      //
-      return pageMD;
-   }
-
-   public String toString()
-   {
-      return "Page[" + getName() + "]";
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,191 +0,0 @@
-/******************************************************************************
- * 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.metadata;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.portal.PortalContainer;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ModesMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.WindowStatesMetaData;
-import org.w3c.dom.Element;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortalMetaData extends PortalObjectMetaData
-{
-
-   private ModesMetaData modes;
-   private WindowStatesMetaData windowStates;
-
-   public PortalMetaData()
-   {
-      modes = new ModesMetaData();
-      modes.add("edit");
-      modes.add("view");
-      modes.add("help");
-      windowStates = new WindowStatesMetaData();
-      windowStates.add("maximized");
-      windowStates.add("minimized");
-      windowStates.add("normal");
-   }
-
-   public ModesMetaData getModes()
-   {
-      return modes;
-   }
-
-   public void setModes(ModesMetaData modes)
-   {
-      this.modes = modes;
-   }
-
-   public WindowStatesMetaData getWindowStates()
-   {
-      return windowStates;
-   }
-
-   public void setWindowStates(WindowStatesMetaData windowStates)
-   {
-      this.windowStates = windowStates;
-   }
-
-   public PortalObject create(PortalObject parent, BuildContext buildContext) throws Exception
-   {
-      if (!(parent instanceof PortalContainer))
-      {
-         throw new IllegalArgumentException("Not a context");
-      }
-
-      //
-      Portal portal = ((PortalContainer)parent).createPortal(getName());
-
-      //
-      configure(portal, buildContext);
-
-      //
-      for (Iterator i = modes.getAll(); i.hasNext();)
-      {
-         String modeName = (String)i.next();
-         Mode mode = Mode.create(modeName);
-         portal.getSupportedModes().add(mode);
-      }
-
-      //
-      for (Iterator i = windowStates.getAll(); i.hasNext();)
-      {
-         String windowStateName = (String)i.next();
-         WindowState windowState = WindowState.create(windowStateName);
-         portal.getSupportedWindowStates().add(windowState);
-      }
-
-      //
-      for (Iterator i = getChildren().values().iterator(); i.hasNext();)
-      {
-         PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)i.next();
-         portalObjectMD.create(portal, buildContext);
-      }
-
-      return portal;
-   }
-
-   /** Parse the following XML elements : portal-name, supported-modes, supported-window-states. */
-   public static PortalMetaData buildPortalMetaData(Element portalElt) throws Exception
-   {
-      PortalMetaData portalMD = new PortalMetaData();
-
-      //
-      String portalName = XML.asString(XML.getUniqueChild(portalElt, "portal-name", true));
-      if (portalName != null && portalName.length() > 0 && portalName.indexOf(".") < 0)
-      {
-         portalMD.setName(portalName);
-      }
-      else
-      {
-         throw new IllegalArgumentException("Invalid portal-name: '" + portalName
-            + "'. Must not be null, empty or contain a '.'");
-      }
-
-      //
-      Element supportedModesElt = XML.getUniqueChild(portalElt, "supported-modes", false);
-      if (supportedModesElt != null)
-      {
-         buildSupportedModes(portalMD, supportedModesElt);
-      }
-
-      //
-      Element supportedWindowStatesElt = XML.getUniqueChild(portalElt, "supported-window-states", false);
-      if (supportedWindowStatesElt != null)
-      {
-         buildSupportedWindowStates(portalMD, supportedWindowStatesElt);
-      }
-
-      //
-      List pageElts = XML.getChildren(portalElt, "page");
-      for (int i = 0; i < pageElts.size(); i++)
-      {
-         Element pageElt = (Element)pageElts.get(i);
-         PageMetaData pageMD = (PageMetaData)PortalObjectMetaData.buildMetaData(pageElt);
-         portalMD.getChildren().put(pageMD.getName(), pageMD);
-      }
-
-      //
-      return portalMD;
-   }
-
-   public static void buildSupportedModes(PortalMetaData portalMD, Element supportedModesElt)
-   {
-      ModesMetaData modesMD = portalMD.getModes();
-      List modeElts = XML.getChildren(supportedModesElt, "mode");
-      for (int i = 0; i < modeElts.size(); i++)
-      {
-         Element modeElt = (Element)modeElts.get(i);
-         String modeAsString = XML.asString(modeElt);
-         modesMD.add(modeAsString);
-      }
-   }
-
-   public static void buildSupportedWindowStates(PortalMetaData portalMD, Element supportedWindowStatesElt)
-   {
-      WindowStatesMetaData windowStateMD = portalMD.getWindowStates();
-      List windowState = XML.getChildren(supportedWindowStatesElt, "window-state");
-      for (int i = 0; i < windowState.size(); i++)
-      {
-         Element windowStateElt = (Element)windowState.get(i);
-         String windowStateAsString = XML.asString(windowStateElt);
-         windowStateMD.add(windowStateAsString);
-      }
-   }
-
-   public String toString()
-   {
-      return "Portal[" + getName() + "]";
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,262 +0,0 @@
-/******************************************************************************
- * 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.metadata;
-
-import org.jboss.logging.Logger;
-import org.jboss.portal.common.metadata.MetaData;
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.security.RoleSecurityBinding;
-import org.jboss.portal.security.SecurityConstants;
-import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
-import org.jboss.portal.security.spi.provider.DomainConfigurator;
-import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
-import org.w3c.dom.Element;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class PortalObjectMetaData implements MetaData
-{
-
-   private static Logger log = Logger.getLogger(PortalObjectMetaData.class);
-   private static boolean trace = log.isTraceEnabled();
-   private String name;
-   private String listener;
-   private Map properties;
-   private Map children;
-   private SecurityConstraintsMetaData securityConstraints;
-
-   public PortalObjectMetaData()
-   {
-      properties = new HashMap();
-      children = new HashMap();
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public String getListener()
-   {
-      return listener;
-   }
-
-   public void setListener(String listener)
-   {
-      this.listener = listener;
-   }
-
-   public Map getProperties()
-   {
-      return properties;
-   }
-
-   public void setProperties(Map properties)
-   {
-      this.properties = properties;
-   }
-
-   public Map getChildren()
-   {
-      return children;
-   }
-
-   public void setChildren(Map children)
-   {
-      this.children = children;
-   }
-
-   public SecurityConstraintsMetaData getSecurityConstraints()
-   {
-      return securityConstraints;
-   }
-
-   public void setSecurityConstraints(SecurityConstraintsMetaData securityConstraints)
-   {
-      this.securityConstraints = securityConstraints;
-   }
-
-   /**
-    * Create an instance of the corresponding portal object.
-    *
-    * @param parent       the parent object
-    * @param buildContext the context
-    * @return the corresponding portal object
-    * @throws Exception any exception
-    */
-   public abstract PortalObject create(PortalObject parent, BuildContext buildContext) throws Exception;
-
-   protected void configure(PortalObject object, BuildContext buildContext) throws SecurityConfigurationException
-   {
-      // Configure properties
-      for (Iterator i = properties.entrySet().iterator(); i.hasNext();)
-      {
-         Map.Entry entry = (Map.Entry)i.next();
-         String name = (String)entry.getKey();
-         String value = (String)entry.getValue();
-         object.setDeclaredProperty(name, value);
-      }
-
-      // Configure listener
-      object.setListener(listener);
-
-      // Configure security
-      SecurityConstraintsMetaData securityConstraints = getSecurityConstraints();
-      if (securityConstraints == null)
-      {
-         if (this instanceof PortalMetaData)
-         {
-            // Default is view recursive
-            securityConstraints = new SecurityConstraintsMetaData();
-            RoleSecurityBinding binding = new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME);
-            securityConstraints.getConstraints().add(binding);
-         }
-      }
-      else
-      {
-         // Skip window configuration
-         if (this instanceof WindowMetaData)
-         {
-            securityConstraints = null;
-            log.warn("Window " + getName() + " has security a " +
-               "configuration but it is not taken in account, portlet instance configuration should be done rather");
-         }
-      }
-
-      //
-      if (securityConstraints != null)
-      {
-         // Apply the constraint
-         PortalObjectContainer poc = buildContext.getContainer();
-         DomainConfigurator domainConfigurator = poc.getAuthorizationDomain().getConfigurator();
-         domainConfigurator.setSecurityBindings(object.getId().toString(PortalObjectId.CANONICAL_FORMAT), securityConstraints.getConstraints());
-      }
-   }
-
-   public static PortalObjectMetaData buildMetaData(Element portalObjectElt) throws Exception
-   {
-      String type = portalObjectElt.getTagName();
-      PortalObjectMetaData portalObjectMD = null;
-      if ("portal".equals(type))
-      {
-         portalObjectMD = PortalMetaData.buildPortalMetaData(portalObjectElt);
-      }
-      else if ("page".equals(type))
-      {
-         portalObjectMD = PageMetaData.buildPageMetaData(portalObjectElt);
-      }
-      else if ("window".equals(type))
-      {
-         portalObjectMD = WindowMetaData.buildWindowMetaData(portalObjectElt);
-      }
-      else if ("context".equals(type))
-      {
-         portalObjectMD = ContextMetaData.buildContextMetaData(portalObjectElt);
-      }
-
-      // Parse common XML stuff
-      if (portalObjectMD != null)
-      {
-         // Add the security constraints
-         Element securityConstraintElt = XML.getUniqueChild(portalObjectElt, "security-constraint", false);
-         if (securityConstraintElt != null)
-         {
-            SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
-            portalObjectMD.setSecurityConstraints(securityConstraintsMD);
-         }
-
-         // Configure properties
-         Element propertiesElt = XML.getUniqueChild(portalObjectElt, "properties", false);
-         if (propertiesElt != null)
-         {
-            buildPropertiesMetaData(portalObjectMD, propertiesElt);
-         }
-
-         // Configure listener
-         Element listenerElt = XML.getUniqueChild(portalObjectElt, "listener", false);
-         if (listenerElt != null)
-         {
-            buildListenerMetaData(portalObjectMD, listenerElt);
-         }
-      }
-      return portalObjectMD;
-   }
-
-   public static void buildPropertiesMetaData(PortalObjectMetaData portalObjectMD, Element propertiesElt)
-   {
-      List propertyElts = XML.getChildren(propertiesElt, "property");
-      for (int i = 0; i < propertyElts.size(); i++)
-      {
-         Element propertyElt = (Element)propertyElts.get(i);
-         Element nameElt = XML.getUniqueChild(propertyElt, "name", true);
-         Element valueElt = XML.getUniqueChild(propertyElt, "value", true);
-         String name = XML.asString(nameElt);
-         String value = XML.asString(valueElt);
-
-         // log.debug("Found property " + name + " = " + value);
-         portalObjectMD.getProperties().put(name, value);
-      }
-   }
-
-   public static void buildListenerMetaData(PortalObjectMetaData portalObjectMD, Element listenerElt)
-   {
-      String listener = XML.asString(listenerElt);
-      portalObjectMD.setListener(listener);
-   }
-
-   /** Define the spi for creating a portal object. */
-   public interface BuildContext
-   {
-      PortalObjectContainer getContainer();
-
-      /** Resolve the instance reference. */
-      String resolveInstanceRef(String ref);
-
-      /** Resolve the parent ref */
-      String resolveParentRef(String ref);
-   }
-
-   public String toString()
-   {
-      String name = getClass().getName();
-      int start = name.lastIndexOf(".");
-      int end = name.length() - start;
-      return name.substring(start, end) + "[" + name + "]";
-   }
-}

Deleted: trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -1,129 +0,0 @@
-/******************************************************************************
- * 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.metadata;
-
-import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.theme.ThemeConstants;
-import org.w3c.dom.Element;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class WindowMetaData extends PortalObjectMetaData
-{
-   /** The window region. */
-   protected String region;
-
-   /** The window order. */
-   protected int order;
-
-   /** The instance handle of this window. */
-   protected String instanceRef;
-
-   public String getInstanceRef()
-   {
-      return instanceRef;
-   }
-
-   public void setInstanceRef(String instanceRef)
-   {
-      this.instanceRef = instanceRef;
-   }
-
-   public String getRegion()
-   {
-      return region;
-   }
-
-   public void setRegion(String region)
-   {
-      this.region = region;
-   }
-
-   public int getOrder()
-   {
-      return order;
-   }
-
-   public void setOrder(int order)
-   {
-      this.order = order;
-   }
-
-   public PortalObject create(PortalObject parent, BuildContext buildContext) throws Exception
-   {
-      if (!(parent instanceof Page))
-      {
-         throw new IllegalArgumentException("Not a page");
-      }
-
-      //
-      Window window = ((Page)parent).createWindow(getName());
-
-      //
-      configure(window, buildContext);
-
-      //
-      String resolvedRef = buildContext.resolveInstanceRef(instanceRef);
-      window.setInstanceRef(resolvedRef);
-
-      //
-      window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, region);
-      window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + order);
-
-      return window;
-   }
-
-   public static WindowMetaData buildWindowMetaData(Element windowElt) throws Exception
-   {
-      WindowMetaData windowMD = new WindowMetaData();
-
-      //
-      String windowName = XML.asString(XML.getUniqueChild(windowElt, "window-name", true));
-      windowMD.setName(windowName);
-
-      // Build instance ref
-      String instanceRef = XML.asString(XML.getUniqueChild(windowElt, "instance-ref", true));
-      windowMD.setInstanceRef(instanceRef);
-
-      // Get coordinates
-      String region = XML.asString(XML.getUniqueChild(windowElt, "region", true));
-      windowMD.setRegion(region);
-
-      //
-      int height = Integer.parseInt(XML.asString(XML.getUniqueChild(windowElt, "height", true)));
-      windowMD.setOrder(height);
-
-      //
-      return windowMD;
-   }
-
-   public String toString()
-   {
-      return "Window[" + getName() + "]";
-   }
-}

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/Page.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/Page.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/Page.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -22,6 +22,8 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal;
 
+import org.jboss.portal.core.model.content.ContentType;
+
 /**
  * A page contains window and is also a page container which can contain nested pages.
  *
@@ -51,9 +53,10 @@
     * Create a new window.
     *
     * @param name window name
+    * @param contentType the window content type
     * @return the created window
     * @throws DuplicatePortalObjectException if a portal object with the specified name already exist
     * @throws IllegalArgumentException if the name is null
     */
-   Window createWindow(String name) throws DuplicatePortalObjectException, IllegalArgumentException;
+   Window createWindow(String name, ContentType contentType) throws DuplicatePortalObjectException, IllegalArgumentException;
 }

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/Window.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/Window.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/Window.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -22,26 +22,20 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal;
 
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentType;
+
 /**
- * Represents a window, i.e the state of the ternary relationship a page has with portlet instances.
+ * Represents a window, i.e the view port to integrated content.
  *
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
 public interface Window extends PortalObject
 {
-   /**
-    * Return the instance reference.
-    *
-    * @return the instance reference
-    *
-    */
-   String getInstanceRef();
+   String getURI();
 
-   /**
-    * Update the instance ref.
-    *
-    * @param instanceRef the instance ref
-    */
-   void setInstanceRef(String instanceRef);
+   ContentType getContentType();
+
+   Content getContent();
 }

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowActionCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowActionCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -25,6 +25,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.portal.Mode;
 import org.jboss.portal.WindowState;
+import org.jboss.portal.identity.User;
 import org.jboss.portal.core.controller.ControllerException;
 import org.jboss.portal.core.controller.ResourceNotFoundException;
 import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
@@ -32,6 +33,7 @@
 import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
 import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.instance.Instance;
 import org.jboss.portal.portlet.NoSuchPortletException;
 import org.jboss.portal.portlet.PortletParameters;
 import org.jboss.portal.portlet.PortletInvokerException;
@@ -61,6 +63,9 @@
    /** . */
    private PortletParameters formParameters;
 
+   /** The instance. */
+   protected Instance instance;
+
    public InvokePortletWindowActionCommand(
       PortalObjectId windowId,
       Mode mode,
@@ -106,6 +111,23 @@
       return info;
    }
 
+   public void create() throws ControllerException
+   {
+      super.create();
+
+      // We need the user id
+      User user = getControllerContext().getUser();
+
+      // Get instance
+      instance = context.getController().getCustomizationManager().getInstance(window, user);
+
+      // No instance means we can't continue
+      if (instance == null)
+      {
+         throw new ResourceNotFoundException(window.getURI());
+      }
+   }
+
    public Object execute() throws ControllerException
    {
       try

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -34,6 +34,8 @@
 import org.jboss.portal.theme.navigation.WindowNavigationalState;
 
 /**
+ * Simply update the navigational state of the window. No invocation to the underlying is done.
+ *
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
@@ -79,30 +81,35 @@
    public Object execute() throws InvocationException
    {
       InvocationContext ctx = getContext();
+      PortalObjectId windowId = window.getId();
 
       //
       if (navigationalState != null)
       {
-         ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef(), navigationalState);
+         ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
       }
 
       // Update the window nav state
-      WindowNavigationalState windowNavState = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef() + "_window");
+      WindowNavigationalState windowNavState = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window");
       if (windowNavState == null)
       {
          windowNavState = new WindowNavigationalState();
-         ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
+         ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window", windowNavState);
       }
+
+      //
       if (mode != null)
       {
          windowNavState.setMode(mode);
       }
+
+      //
       if (windowState != null)
       {
          windowNavState.setWindowState(windowState);
       }
 
       //
-      return new UpdateWindowMarkupResponse(window.getId());
+      return new UpdateWindowMarkupResponse(windowId);
    }
 }
\ No newline at end of file

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokeWindowCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -24,7 +24,6 @@
 
 import org.jboss.portal.Mode;
 import org.jboss.portal.WindowState;
-import org.jboss.portal.core.model.portal.command.WindowCommand;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 
 /**

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -22,41 +22,25 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal.command;
 
-import org.jboss.portal.Mode;
 import org.jboss.portal.WindowState;
 import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.util.Exceptions;
 import org.jboss.portal.core.controller.ControllerContext;
 import org.jboss.portal.core.controller.ControllerException;
 import org.jboss.portal.core.controller.ControllerSecurityException;
-import org.jboss.portal.core.controller.ResourceAccessDeniedException;
-import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.portlet.PortletResponse;
 import org.jboss.portal.core.controller.command.info.CommandInfo;
 import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
-import org.jboss.portal.core.model.instance.Instance;
 import org.jboss.portal.core.model.portal.Page;
 import org.jboss.portal.core.model.portal.PortalObject;
 import org.jboss.portal.core.model.portal.PortalObjectPermission;
 import org.jboss.portal.core.model.portal.Window;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.cms.command.RenderCMSWindowCommand;
 import org.jboss.portal.identity.User;
 import org.jboss.portal.identity.UserProfileModule;
-import org.jboss.portal.portlet.Properties;
-import org.jboss.portal.portlet.info.ModeInfo;
-import org.jboss.portal.portlet.info.WindowStateInfo;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
 import org.jboss.portal.security.PortalSecurityException;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
 import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.server.config.ServerConfig;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
 import org.jboss.portal.theme.LayoutService;
 import org.jboss.portal.theme.PageRendition;
 import org.jboss.portal.theme.PortalLayout;
@@ -65,7 +49,6 @@
 import org.jboss.portal.theme.ThemeConstants;
 import org.jboss.portal.theme.ThemeResult;
 import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
 import org.jboss.portal.theme.page.PageResult;
 import org.jboss.portal.theme.page.PageService;
 import org.jboss.portal.theme.page.WindowResult;
@@ -76,11 +59,9 @@
 import javax.naming.NamingException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.StringTokenizer;
 
 /**
@@ -92,59 +73,16 @@
 public final class RenderPageCommand extends PageCommand
 {
 
-   /**
-    * .
-    */
-   private static String WINDOW_ACCESS_DENIED = "core.render.window_access_denied";
-
-   /**
-    * .
-    */
-   private static String WINDOW_UNAVAILABLE = "core.render.window_unavailable";
-
-   /**
-    * .
-    */
-   private static String WINDOW_ERROR = "core.render.window_error";
-
-   /**
-    * .
-    */
-   private static String WINDOW_INTERNAL_ERROR = "core.render.window_internal_error";
-
-   /**
-    * .
-    */
-   private static String WINDOW_NOT_FOUND = "core.render.window_not_found";
-
-   /**
-    * .
-    */
-   private static String HIDE = "hide";
-
-   /**
-    * .
-    */
-   private static String SHOW = "show";
-
-   /**
-    * .
-    */
+   /** . */
    private static final CommandInfo info = new ViewCommandInfo(false, "view");
 
-   /**
-    * The windows to render.
-    */
+   /** The windows to render. */
    private Collection windows;
 
-   /**
-    * .
-    */
+   /** . */
    private PortalLayout layout;
 
-   /**
-    * .
-    */
+   /** . */
    private boolean personalizable;
 
    public RenderPageCommand(PortalObjectId pageId)
@@ -263,7 +201,6 @@
          }
 
          // Call the portlet container to create the markup fragment(s) for each portlet that needs to render itself
-         ServerConfig cfg = sinv.getRequest().getServer().getConfig();
          PageResult pageResult = new PageResult(getPage().getName(), new HashMap(getPage().getDeclaredProperties()), new HashMap(getPage().getPortal().getDeclaredProperties()));
 
          // Set the layout uri
@@ -279,7 +216,21 @@
                boolean visible = true;
                if (visible)
                {
-                  Object res = renderPortletWindow(cfg, window);
+                  ContentType contentType = window.getContentType();
+
+                  //
+                  RenderWindowCommand renderCmd = null;
+                  if (ContentType.PORTLET.equals(contentType))
+                  {
+                     renderCmd = new RenderPortletWindowCommand(window.getId());
+                  }
+                  else if (ContentType.CMS.equals(contentType))
+                  {
+                     renderCmd = new RenderCMSWindowCommand(window.getId());
+                  }
+
+                  //
+                  Object res = context.execute(renderCmd);
                   if (res == null)
                   {
                      // Skip
@@ -335,7 +286,6 @@
             }
          }
 
-
          // Make the theme available as servlet request attribute (needed for CM)
          if (theme != null)
          {
@@ -371,7 +321,7 @@
       // If the id is provided in the form of context.name then look up the theme via a registration id
       if (themeIdString.lastIndexOf(".") > 0)
       {
-         ServerRegistrationID themeId = ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseID(themeIdString));
+         ServerRegistrationID themeId = ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseId(themeIdString));
          return service.getTheme(themeId, true);
       }
       else
@@ -392,32 +342,32 @@
     */
    public static PortalLayout getLayout(LayoutService layoutService, Page page)
    {
-      String layoutIDString = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+      String layoutIdString = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
 
       // Last resort: use the nodesk layout
-      if (layoutIDString == null)
+      if (layoutIdString == null)
       {
-         layoutIDString = "nodesk";
+         layoutIdString = "nodesk";
       }
 
       //
       PortalLayout layout;
-      if (layoutIDString.lastIndexOf(".") > 0)
+      if (layoutIdString.lastIndexOf(".") > 0)
       {
          // if the id is provided in the form of context.name then look up the layout via a registration id
-         ServerRegistrationID layoutID = ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT, parseID(layoutIDString));
+         ServerRegistrationID layoutID = ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT, parseId(layoutIdString));
          layout = layoutService.getLayout(layoutID, true);
       }
       else
       {
          // otherwise use the ordinary layout name provided and lookup the layout via the name
-         layout = layoutService.getLayout(layoutIDString, true);
+         layout = layoutService.getLayout(layoutIdString, true);
       }
 
       // We don't like that situation
       if (layout == null)
       {
-         throw new IllegalStateException("NO LAYOUT FOUND FOR " + layoutIDString);
+         throw new IllegalStateException("NO LAYOUT FOUND FOR " + layoutIdString);
       }
 
       //
@@ -425,202 +375,13 @@
    }
 
    /**
-    * Call the component container to render the markup fragment of a window
-    *
-    * @param cfg    the server config to get information about the error behaviour
-    * @param window the window to render
-    * @return a result containing markup, or other result information (redirect url, etc.)
-    * @throws InvocationException
-    */
-   protected Object renderPortletWindow(ServerConfig cfg, Window window) throws ControllerException
-   {
-      // Execute render command
-      PortalObjectId windowId = window.getId();
-
-      //
-      String windowTitle;
-      String contentChars = "";
-      String headerChars = null;
-      Map actionMap = new HashMap();
-      Map windowProps = window.getDeclaredProperties();
-
-      String navStateKey = window.getId() + "_window";
-      WindowNavigationalState windowNavState = (WindowNavigationalState)context.getAttribute(NAVIGATIONAL_STATE_SCOPE, navStateKey);
-      if (windowNavState == null)
-      {
-         windowNavState = new WindowNavigationalState();
-         context.setAttribute(NAVIGATIONAL_STATE_SCOPE, navStateKey, windowNavState);
-      }
-
-      try
-      {
-         RenderPortletWindowCommand renderCmd = new RenderPortletWindowCommand(windowId);
-         PortletResponse portletResponse = (PortletResponse)context.execute(renderCmd);
-         PortletInvocationResponse response = portletResponse.getResult();
-
-         //
-         if (response instanceof FragmentResponse)
-         {
-            FragmentResponse fragment = (FragmentResponse)response;
-            windowTitle = fragment.getTitle();
-            if (windowTitle == null)
-            {
-               windowTitle = window.getName();
-            }
-            headerChars = fragment.getHeader();
-
-            //
-            Instance instance = renderCmd.getInstance();
-
-            //
-            List supportedWindowStates = new ArrayList();
-            for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllWindowStates().iterator(); i.hasNext();)
-            {
-               WindowStateInfo windowStateInfo = (WindowStateInfo)i.next();
-               WindowState windowState = windowStateInfo.getWindowState();
-               if (portal.getSupportedWindowStates().contains(windowState))
-               {
-                  supportedWindowStates.add(windowState);
-               }
-            }
-
-            //
-            List supportedModes = new ArrayList();
-            for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllModes().iterator(); i.hasNext();)
-            {
-               ModeInfo modeInfo = (ModeInfo)i.next();
-               Mode mode = modeInfo.getMode();
-               if (portal.getSupportedModes().contains(mode))
-               {
-                  supportedModes.add(mode);
-               }
-            }
-
-            // Remove edit mode if the user is not logged it
-            if (getControllerContext().getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() == null)
-            {
-               supportedModes.remove(Mode.EDIT);
-            }
-
-            //
-            addModeActions(window, actionMap, windowNavState.getMode(), supportedModes);
-
-            //
-            addStateActions(window, actionMap, windowNavState.getWindowState(), supportedWindowStates);
-
-            //
-            contentChars = fragment.getContent();
-
-            //
-            return new WindowResult(
-               windowTitle,
-               contentChars,
-               actionMap,
-               windowProps,
-               new Properties(),
-               headerChars,
-               windowNavState.getWindowState(),
-               windowNavState.getMode());
-         }
-         else if (response instanceof ErrorResponse)
-         {
-            ErrorResponse errorResult = (ErrorResponse)response;
-            String logMessage = "Rendering portlet window " + windowId + " triggered the following error :";
-            errorResult.logErrorTo(log, logMessage);
-            String property = cfg.getProperty(WINDOW_ERROR);
-            if (!HIDE.equals(property))
-            {
-               windowTitle = "An error occured while rendering window '" + windowId + "'";
-               contentChars = errorResult.getMessage();
-               Throwable t = errorResult.getThrowable();
-               if (t != null && SHOW.equals(property))
-               {
-                  contentChars = Exceptions.toHTML(t, true);
-               }
-               return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
-            }
-         }
-         else if (response instanceof UnavailableResponse)
-         {
-            if (SHOW.equals(cfg.getProperty(WINDOW_UNAVAILABLE)))
-            {
-               windowTitle = "Portlet unavailable";
-               contentChars = "Portlet unavailable";
-               actionMap = new HashMap();
-               actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
-               actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
-               return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
-            }
-         }
-         else if (response instanceof InsufficientPrivilegesResponse)
-         {
-            // Julien : go to the section below, I know it is very ugly
-            throw new ResourceAccessDeniedException(windowId.toString());
-         }
-         else
-         {
-            return portletResponse;
-         }
-      }
-      catch (ResourceAccessDeniedException e)
-      {
-         if (log.isTraceEnabled())
-         {
-            log.trace("Window access denied", e);
-         }
-         if (SHOW.equals(cfg.getProperty(WINDOW_ACCESS_DENIED)))
-         {
-            actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
-            actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
-            windowTitle = "Access denied";
-            contentChars = "Access denied";
-            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
-         }
-      }
-      catch (ResourceNotFoundException e)
-      {
-         if (log.isTraceEnabled())
-         {
-            log.trace("Window not found", e);
-         }
-         if (SHOW.equals(cfg.getProperty(WINDOW_NOT_FOUND)))
-         {
-            actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
-            actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
-            windowTitle = "Cannot render";
-            contentChars = "Object not found " + e.getRef();
-            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
-         }
-      }
-      catch (ControllerException e)
-      {
-         // It's a CommandException that we rethrow
-         throw e;
-      }
-      catch (Exception e)
-      {
-         log.error("Rendering portlet window " + windowId + " produced an internal error", e);
-         String property = cfg.getProperty(WINDOW_INTERNAL_ERROR);
-         if (SHOW.equals(property))
-         {
-            windowTitle = "An internal error occured while rendering window '" + window + "'";
-            contentChars = Exceptions.toHTML(e, true);
-            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
-         }
-      }
-
-      //
-      return null;
-   }
-
-   /**
     * parse the provided String for '.' as a separator. For each token, add an entry to a String[] that will be returned
     * as the result
     *
     * @param layoutIDString the string to be examined
     * @return an array of Strings
     */
-   private static String[] parseID(String layoutIDString)
+   private static String[] parseId(String layoutIDString)
    {
       List names = new ArrayList();
       StringTokenizer tokens = new StringTokenizer(layoutIDString, ".");
@@ -640,51 +401,4 @@
       names.toArray(id);
       return id;
    }
-
-   /**
-    * Create the action URLs for the allowed window states of the rendered portlet window and add them to the provided
-    * actionMap.
-    */
-   private void addStateActions(Window window, Map actionMap, WindowState currentWindowState, List supportedWindowStates)
-   {
-      List windowStates = new ArrayList(supportedWindowStates.size());
-      for (Iterator j = supportedWindowStates.iterator(); j.hasNext();)
-      {
-         WindowState windowState = (WindowState)j.next();
-         String url = createUpdateNavigationalStateURL(window, null, windowState);
-         boolean disabled = windowState.equals(currentWindowState);
-         WindowResult.Action action = new WindowResult.Action(windowState, url, !disabled);
-         windowStates.add(action);
-      }
-      actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
-   }
-
-   /**
-    * Create the action URLs for the allowed portlet modes of the rendered portlet window and add them to the provided
-    * actionMap.
-    */
-   private void addModeActions(Window window, Map actionMap, Mode currentMode, List supportedModes)
-   {
-      List modes = new ArrayList(supportedModes.size());
-      for (Iterator j = supportedModes.iterator(); j.hasNext();)
-      {
-         Mode mode = (Mode)j.next();
-         String url = createUpdateNavigationalStateURL(window, mode, null);
-         boolean disabled = mode.equals(currentMode);
-         WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
-         modes.add(action);
-      }
-      actionMap.put(WindowResult.MODES_KEY, modes);
-   }
-
-   public String createUpdateNavigationalStateURL(Window window, Mode mode, WindowState windowState)
-   {
-      InvokePortletWindowRenderCommand cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
-      ControllerContext controllerContext = getControllerContext();
-      ServerInvocationContext serverContext = controllerContext.getServerInvocation().getServerContext();
-      boolean secure = serverContext.getURLContext().getSecure();
-      boolean authenticated = serverContext.getURLContext().isAuthenticated();
-      URLContext urlContext = URLContext.newInstance(secure, authenticated);
-      return controllerContext.renderURL(cmd, urlContext, URLFormat.newInstance(true, true));
-   }
 }

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPortletWindowCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -22,61 +22,105 @@
  ******************************************************************************/
 package org.jboss.portal.core.model.portal.command;
 
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
+import org.jboss.portal.core.model.instance.Instance;
 import org.jboss.portal.core.controller.ControllerException;
 import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.ResourceAccessDeniedException;
+import org.jboss.portal.core.controller.ControllerContext;
 import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
-import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
-import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.server.config.ServerConfig;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
 import org.jboss.portal.portlet.NoSuchPortletException;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.Properties;
+import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.portlet.info.ModeInfo;
 import org.jboss.portal.portlet.invocation.RenderInvocation;
 import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
 import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.Exceptions;
 
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collections;
+
 /**
  * Render a single window.
  *
  * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
  * @version $Revision$
  */
-public class RenderPortletWindowCommand extends WindowCommand
+public class RenderPortletWindowCommand extends RenderWindowCommand
 {
 
-   /** . */
-   private static final CommandInfo info = new ViewCommandInfo(true, "view");
-
    public RenderPortletWindowCommand(PortalObjectId windowId) throws IllegalArgumentException
    {
       super(windowId);
    }
 
-   public CommandInfo getInfo()
+   /** The instance. */
+   protected Instance instance;
+
+   public void create() throws ControllerException
    {
-      return info;
+      super.create();
+
+      //
+      instance = findInstance();
+
+      // No instance means we can't continue
+      if (instance == null)
+      {
+         throw new ResourceNotFoundException(window.getURI());
+      }
    }
 
+   protected Instance findInstance()
+   {
+      // We need the user id
+      User user = getControllerContext().getUser();
+
+      // Get instance
+      return context.getController().getCustomizationManager().getInstance(window, user);
+   }
+
    public Object execute() throws ControllerException
    {
-      StateString navigationalState = (StateString)getAttribute(NAVIGATIONAL_STATE_SCOPE, window.getInstanceRef());
+      //
+      ServerConfig cfg = getControllerContext().getServerInvocation().getRequest().getServer().getConfig();
 
       //
-      String navStateKey = window.getId() + "_window";
+      PortalObjectId windowId = window.getId();
+
+      //
+      StateString navigationalState = (StateString)getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId);
+
+      // Get mode and window state
+      String navStateKey = windowId + "_window";
       WindowNavigationalState windowNavState = (WindowNavigationalState)getAttribute(NAVIGATIONAL_STATE_SCOPE, navStateKey);
       if (windowNavState == null)
       {
          windowNavState = new WindowNavigationalState();
          setAttribute(NAVIGATIONAL_STATE_SCOPE, navStateKey, windowNavState);
       }
-
-      // Get the mode
       Mode mode = windowNavState.getMode();
-
-      // Get the window state
       WindowState windowState = windowNavState.getWindowState();
 
       //
@@ -89,23 +133,229 @@
          portal);
 
       //
+      String windowTitle;
+      String contentChars;
+      String headerChars = null;
+      Map actionMap = new HashMap();
+      Map windowProps = window.getDeclaredProperties();
+
+      //
       try
       {
-         PortletInvocationResponse resp = instance.invoke(invocation);
+         //
+         PortletInvocationResponse response;
+         try
+         {
+            response = instance.invoke(invocation);
+         }
+         catch (PortletInvokerException e)
+         {
+            if (e instanceof NoSuchPortletException)
+            {
+               throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
+            }
+            else
+            {
+               throw new ControllerException(e);
+            }
+         }
 
          //
-         return new PortletWindowResponse(targetId, resp);
+         if (response instanceof FragmentResponse)
+         {
+            FragmentResponse fragment = (FragmentResponse)response;
+            windowTitle = fragment.getTitle();
+            if (windowTitle == null)
+            {
+               windowTitle = window.getName();
+            }
+            headerChars = fragment.getHeader();
+
+            //
+            List supportedWindowStates = new ArrayList();
+            for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllWindowStates().iterator(); i.hasNext();)
+            {
+               WindowStateInfo windowStateInfo = (WindowStateInfo)i.next();
+               WindowState tmp = windowStateInfo.getWindowState();
+               if (portal.getSupportedWindowStates().contains(tmp))
+               {
+                  supportedWindowStates.add(tmp);
+               }
+            }
+
+            //
+            List supportedModes = new ArrayList();
+            for (Iterator i = instance.getPortlet().getInfo().getCapabilities().getAllModes().iterator(); i.hasNext();)
+            {
+               ModeInfo modeInfo = (ModeInfo)i.next();
+               Mode tmp = modeInfo.getMode();
+               if (portal.getSupportedModes().contains(tmp))
+               {
+                  supportedModes.add(tmp);
+               }
+            }
+
+            // Remove edit mode if the user is not logged it
+            if (getControllerContext().getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() == null)
+            {
+               supportedModes.remove(Mode.EDIT);
+            }
+
+            //
+            addModeActions(window, actionMap, windowNavState.getMode(), supportedModes);
+
+            //
+            addStateActions(window, actionMap, windowNavState.getWindowState(), supportedWindowStates);
+
+            //
+            contentChars = fragment.getContent();
+
+            //
+            return new WindowResult(
+               windowTitle,
+               contentChars,
+               actionMap,
+               windowProps,
+               new Properties(),
+               headerChars,
+               windowNavState.getWindowState(),
+               windowNavState.getMode());
+         }
+         else if (response instanceof ErrorResponse)
+         {
+            ErrorResponse errorResult = (ErrorResponse)response;
+            String logMessage = "Rendering portlet window " + windowId + " triggered the following error :";
+            errorResult.logErrorTo(log, logMessage);
+            String property = cfg.getProperty(WINDOW_ERROR);
+            if (!HIDE.equals(property))
+            {
+               windowTitle = "An error occured while rendering window '" + windowId + "'";
+               contentChars = errorResult.getMessage();
+               Throwable t = errorResult.getThrowable();
+               if (t != null && SHOW.equals(property))
+               {
+                  contentChars = Exceptions.toHTML(t, true);
+               }
+               return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+            }
+         }
+         else if (response instanceof UnavailableResponse)
+         {
+            if (SHOW.equals(cfg.getProperty(WINDOW_UNAVAILABLE)))
+            {
+               windowTitle = "Portlet unavailable";
+               contentChars = "Portlet unavailable";
+               actionMap = new HashMap();
+               actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+               actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+               return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+            }
+         }
+         else if (response instanceof InsufficientPrivilegesResponse)
+         {
+            // Julien : go to the section below, I know it is very ugly
+            throw new ResourceAccessDeniedException(windowId.toString());
+         }
+         else
+         {
+            return new PortletWindowResponse(windowId, response);
+         }
       }
-      catch (PortletInvokerException e)
+      catch (ResourceAccessDeniedException e)
       {
-         if (e instanceof NoSuchPortletException)
+         if (log.isTraceEnabled())
          {
-            throw new ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
+            log.trace("Window access denied", e);
          }
-         else
+         if (SHOW.equals(cfg.getProperty(WINDOW_ACCESS_DENIED)))
          {
-            throw new ControllerException(e);
+            actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+            actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+            windowTitle = "Access denied";
+            contentChars = "Access denied";
+            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
          }
       }
+      catch (ResourceNotFoundException e)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Window not found", e);
+         }
+         if (SHOW.equals(cfg.getProperty(WINDOW_NOT_FOUND)))
+         {
+            actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+            actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+            windowTitle = "Cannot render";
+            contentChars = "Object not found " + e.getRef();
+            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+         }
+      }
+      catch (ControllerException e)
+      {
+         // It's a CommandException that we rethrow
+         throw e;
+      }
+      catch (Exception e)
+      {
+         log.error("Rendering portlet window " + windowId + " produced an internal error", e);
+         String property = cfg.getProperty(WINDOW_INTERNAL_ERROR);
+         if (SHOW.equals(property))
+         {
+            windowTitle = "An internal error occured while rendering window '" + window + "'";
+            contentChars = Exceptions.toHTML(e, true);
+            return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+         }
+      }
+
+      //
+      return null;
    }
+
+   /**
+    * Create the action URLs for the allowed window states of the rendered portlet window and add them to the provided
+    * actionMap.
+    */
+   private void addStateActions(Window window, Map actionMap, WindowState currentWindowState, List supportedWindowStates)
+   {
+      List windowStates = new ArrayList(supportedWindowStates.size());
+      for (Iterator j = supportedWindowStates.iterator(); j.hasNext();)
+      {
+         WindowState windowState = (WindowState)j.next();
+         String url = createUpdateNavigationalStateURL(window, null, windowState);
+         boolean disabled = windowState.equals(currentWindowState);
+         WindowResult.Action action = new WindowResult.Action(windowState, url, !disabled);
+         windowStates.add(action);
+      }
+      actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
+   }
+
+   /**
+    * Create the action URLs for the allowed portlet modes of the rendered portlet window and add them to the provided
+    * actionMap.
+    */
+   private void addModeActions(Window window, Map actionMap, Mode currentMode, List supportedModes)
+   {
+      List modes = new ArrayList(supportedModes.size());
+      for (Iterator j = supportedModes.iterator(); j.hasNext();)
+      {
+         Mode mode = (Mode)j.next();
+         String url = createUpdateNavigationalStateURL(window, mode, null);
+         boolean disabled = mode.equals(currentMode);
+         WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
+         modes.add(action);
+      }
+      actionMap.put(WindowResult.MODES_KEY, modes);
+   }
+
+   private String createUpdateNavigationalStateURL(Window window, Mode mode, WindowState windowState)
+   {
+      InvokePortletWindowRenderCommand cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
+      ControllerContext controllerContext = getControllerContext();
+      ServerInvocationContext serverContext = controllerContext.getServerInvocation().getServerContext();
+      boolean secure = serverContext.getURLContext().getSecure();
+      boolean authenticated = serverContext.getURLContext().isAuthenticated();
+      URLContext urlContext = URLContext.newInstance(secure, authenticated);
+      return controllerContext.renderURL(cmd, urlContext, URLFormat.newInstance(true, true));
+   }
 }

Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.command;
+
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class RenderWindowCommand extends WindowCommand
+{
+
+   /** . */
+   protected static String WINDOW_ACCESS_DENIED = "core.render.window_access_denied";
+
+   /** . */
+   protected static String WINDOW_UNAVAILABLE = "core.render.window_unavailable";
+
+   /** . */
+   protected static String WINDOW_ERROR = "core.render.window_error";
+
+   /** . */
+   protected static String WINDOW_INTERNAL_ERROR = "core.render.window_internal_error";
+
+   /** . */
+   protected static String WINDOW_NOT_FOUND = "core.render.window_not_found";
+
+   /** . */
+   protected static String HIDE = "hide";
+
+   /** . */
+   protected static String SHOW = "show";
+
+   /** . */
+   private static final CommandInfo info = new ViewCommandInfo(true, "view");
+
+   public RenderWindowCommand(PortalObjectId windowId)
+      throws IllegalArgumentException
+   {
+      super(windowId);
+   }
+
+   public CommandInfo getInfo()
+   {
+      return info;
+   }
+}

Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -25,14 +25,12 @@
 import org.jboss.portal.core.controller.ControllerException;
 import org.jboss.portal.core.controller.ControllerSecurityException;
 import org.jboss.portal.core.controller.ResourceNotFoundException;
-import org.jboss.portal.core.model.instance.Instance;
 import org.jboss.portal.core.model.portal.Page;
 import org.jboss.portal.core.model.portal.Portal;
 import org.jboss.portal.core.model.portal.Window;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 import org.jboss.portal.security.PortalSecurityException;
 import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.identity.User;
 
 /**
  * A superclass for command that target a specific window.
@@ -52,19 +50,11 @@
    /** The window. */
    protected Window window;
 
-   /** The instance. */
-   protected Instance instance;
-
    public WindowCommand(PortalObjectId windowId) throws IllegalArgumentException
    {
       super(windowId);
    }
 
-   public Instance getInstance()
-   {
-      return instance;
-   }
-
    public Portal getPortal()
    {
       return portal;
@@ -100,18 +90,6 @@
       {
          throw new ResourceNotFoundException(targetId.toString());
       }
-
-      // We need the user id
-      User user = getControllerContext().getUser();
-
-      // Get instance
-      instance = context.getController().getCustomizationManager().getInstance(window, user);
-
-      // No instance means we can't continue
-      if (instance == null)
-      {
-         throw new ResourceNotFoundException(window.getInstanceRef());
-      }
    }
 
    /**

Added: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+
+/**
+ * Defines the callbacks for creating a portal object.
+ *
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface BuildContext
+{
+   PortalObjectContainer getContainer();
+
+   ContentHandler getHandler(ContentType contentType);
+}

Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/ContextMetaData.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.portal.metadata.PortalObjectMetaData;
+import org.jboss.portal.core.model.portal.metadata.PortalMetaData;
+import org.jboss.portal.common.util.XML;
+import org.w3c.dom.Element;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContextMetaData extends PortalObjectMetaData
+{
+
+   protected PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception
+   {
+      if (parent instanceof PortalContainer == false)
+      {
+         throw new IllegalArgumentException("Not a context");
+      }
+
+      //
+      return ((PortalContainer)parent).createPortalContainer(getName());
+   }
+
+   /** Parse the following XML elements : context-name. */
+   public static ContextMetaData buildContextMetaData(ContentHandlerRegistry contentHandlerRegistry, Element contextElt) throws Exception
+   {
+      ContextMetaData contextMD = new ContextMetaData();
+
+      //
+      String contextName = XML.asString(XML.getUniqueChild(contextElt, "context-name", true));
+      if (contextName != null && contextName.length() > 0 && contextName.indexOf(".") < 0)
+      {
+         contextMD.setName(contextName);
+      }
+      else
+      {
+         throw new IllegalArgumentException("Invalid context-name: '" + contextName
+            + "'. Must not be null, empty or contain a '.'");
+      }
+
+      //
+      List pageElts = XML.getChildren(contextElt, "portal");
+      for (int i = 0; i < pageElts.size(); i++)
+      {
+         Element portalElt = (Element)pageElts.get(i);
+         PortalMetaData pageMD = (PortalMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, portalElt);
+         contextMD.getChildren().put(pageMD.getName(), pageMD);
+      }
+
+      //
+      return contextMD;
+   }
+}

Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PageMetaData.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.core.model.portal.PageContainer;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.w3c.dom.Element;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PageMetaData extends PortalObjectMetaData
+{
+
+   public PageMetaData()
+   {
+   }
+
+   protected PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception
+   {
+      if (!(parent instanceof PageContainer))
+      {
+         throw new IllegalArgumentException("Cannot build page " + getName() + " because the parent it references is not a page container " + parent);
+      }
+
+      //
+      return ((PageContainer)parent).createPage(getName());
+   }
+
+   public static PageMetaData buildPageMetaData(ContentHandlerRegistry contentHandlerRegistry, Element pageElt)
+   {
+      PageMetaData pageMD = new PageMetaData();
+
+      //
+      String pageName = XML.asString(XML.getUniqueChild(pageElt, "page-name", true));
+      pageMD.setName(pageName);
+
+      // Add the contained getWindows
+      List windowElts = XML.getChildren(pageElt, "window");
+      for (int j = 0; j < windowElts.size(); j++)
+      {
+         Element windowElt = (Element)windowElts.get(j);
+         try
+         {
+            WindowMetaData windowMD = (WindowMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, windowElt);
+            pageMD.getChildren().put(windowMD.getName(), windowMD);
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+      }
+
+      // Add the contained pages
+      List pageElts = XML.getChildren(pageElt, "page");
+      for (int j = 0; j < pageElts.size(); j++)
+      {
+         Element childPageElt = (Element)pageElts.get(j);
+         try
+         {
+            PageMetaData childPageMD = (PageMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, childPageElt);
+            pageMD.getChildren().put(childPageMD.getName(), childPageMD);
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+      }
+
+      //
+      return pageMD;
+   }
+
+   public String toString()
+   {
+      return "Page[" + getName() + "]";
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PortalMetaData.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,184 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.portlet.impl.jsr168.metadata.ModesMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.WindowStatesMetaData;
+import org.w3c.dom.Element;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalMetaData extends PortalObjectMetaData
+{
+
+   private ModesMetaData modes;
+   private WindowStatesMetaData windowStates;
+
+   public PortalMetaData()
+   {
+      modes = new ModesMetaData();
+      modes.add("edit");
+      modes.add("view");
+      modes.add("help");
+      windowStates = new WindowStatesMetaData();
+      windowStates.add("maximized");
+      windowStates.add("minimized");
+      windowStates.add("normal");
+   }
+
+   public ModesMetaData getModes()
+   {
+      return modes;
+   }
+
+   public void setModes(ModesMetaData modes)
+   {
+      this.modes = modes;
+   }
+
+   public WindowStatesMetaData getWindowStates()
+   {
+      return windowStates;
+   }
+
+   public void setWindowStates(WindowStatesMetaData windowStates)
+   {
+      this.windowStates = windowStates;
+   }
+
+
+   protected PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception
+   {
+      if (!(parent instanceof PortalContainer))
+      {
+         throw new IllegalArgumentException("Not a context");
+      }
+
+      //
+      Portal portal = ((PortalContainer)parent).createPortal(getName());
+
+      //
+      for (Iterator i = modes.getAll(); i.hasNext();)
+      {
+         String modeName = (String)i.next();
+         Mode mode = Mode.create(modeName);
+         portal.getSupportedModes().add(mode);
+      }
+
+      //
+      for (Iterator i = windowStates.getAll(); i.hasNext();)
+      {
+         String windowStateName = (String)i.next();
+         WindowState windowState = WindowState.create(windowStateName);
+         portal.getSupportedWindowStates().add(windowState);
+      }
+
+      //
+      return portal;
+   }
+
+   /** Parse the following XML elements : portal-name, supported-modes, supported-window-states. */
+   public static PortalMetaData buildPortalMetaData(ContentHandlerRegistry contentHandlerRegistry, Element portalElt) throws Exception
+   {
+      PortalMetaData portalMD = new PortalMetaData();
+
+      //
+      String portalName = XML.asString(XML.getUniqueChild(portalElt, "portal-name", true));
+      if (portalName != null && portalName.length() > 0 && portalName.indexOf(".") < 0)
+      {
+         portalMD.setName(portalName);
+      }
+      else
+      {
+         throw new IllegalArgumentException("Invalid portal-name: '" + portalName
+            + "'. Must not be null, empty or contain a '.'");
+      }
+
+      //
+      Element supportedModesElt = XML.getUniqueChild(portalElt, "supported-modes", false);
+      if (supportedModesElt != null)
+      {
+         buildSupportedModes(portalMD, supportedModesElt);
+      }
+
+      //
+      Element supportedWindowStatesElt = XML.getUniqueChild(portalElt, "supported-window-states", false);
+      if (supportedWindowStatesElt != null)
+      {
+         buildSupportedWindowStates(portalMD, supportedWindowStatesElt);
+      }
+
+      //
+      List pageElts = XML.getChildren(portalElt, "page");
+      for (int i = 0; i < pageElts.size(); i++)
+      {
+         Element pageElt = (Element)pageElts.get(i);
+         PageMetaData pageMD = (PageMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, pageElt);
+         portalMD.getChildren().put(pageMD.getName(), pageMD);
+      }
+
+      //
+      return portalMD;
+   }
+
+   public static void buildSupportedModes(PortalMetaData portalMD, Element supportedModesElt)
+   {
+      ModesMetaData modesMD = portalMD.getModes();
+      List modeElts = XML.getChildren(supportedModesElt, "mode");
+      for (int i = 0; i < modeElts.size(); i++)
+      {
+         Element modeElt = (Element)modeElts.get(i);
+         String modeAsString = XML.asString(modeElt);
+         modesMD.add(modeAsString);
+      }
+   }
+
+   public static void buildSupportedWindowStates(PortalMetaData portalMD, Element supportedWindowStatesElt)
+   {
+      WindowStatesMetaData windowStateMD = portalMD.getWindowStates();
+      List windowState = XML.getChildren(supportedWindowStatesElt, "window-state");
+      for (int i = 0; i < windowState.size(); i++)
+      {
+         Element windowStateElt = (Element)windowState.get(i);
+         String windowStateAsString = XML.asString(windowStateElt);
+         windowStateMD.add(windowStateAsString);
+      }
+   }
+
+   public String toString()
+   {
+      return "Portal[" + getName() + "]";
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/PortalObjectMetaData.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,277 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.common.metadata.MetaData;
+import org.jboss.portal.common.util.XML;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.security.RoleSecurityBinding;
+import org.jboss.portal.security.SecurityConstants;
+import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
+import org.jboss.portal.security.spi.provider.DomainConfigurator;
+import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
+import org.w3c.dom.Element;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class PortalObjectMetaData implements MetaData
+{
+
+   private static Logger log = Logger.getLogger(PortalObjectMetaData.class);
+
+   private String name;
+   private String listener;
+   private Map properties;
+   private Map children;
+   private SecurityConstraintsMetaData securityConstraints;
+
+   public PortalObjectMetaData()
+   {
+      properties = new HashMap();
+      children = new HashMap();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   public String getListener()
+   {
+      return listener;
+   }
+
+   public void setListener(String listener)
+   {
+      this.listener = listener;
+   }
+
+   public Map getProperties()
+   {
+      return properties;
+   }
+
+   public void setProperties(Map properties)
+   {
+      this.properties = properties;
+   }
+
+   public Map getChildren()
+   {
+      return children;
+   }
+
+   public void setChildren(Map children)
+   {
+      this.children = children;
+   }
+
+   public SecurityConstraintsMetaData getSecurityConstraints()
+   {
+      return securityConstraints;
+   }
+
+   public void setSecurityConstraints(SecurityConstraintsMetaData securityConstraints)
+   {
+      this.securityConstraints = securityConstraints;
+   }
+
+   /**
+    * Create an instance of the corresponding portal object.
+    *
+    * @param buildContext the context
+    * @param parent       the parent object
+    * @return the corresponding portal object
+    * @throws Exception any exception
+    */
+   public final PortalObject create(BuildContext buildContext, PortalObject parent) throws Exception
+   {
+      // Build instance
+      PortalObject object = newInstance(buildContext, parent);
+
+      // Configure common properties
+      configure(buildContext, object);
+
+      // Build children recursively
+      for (Iterator i = getChildren().values().iterator(); i.hasNext();)
+      {
+         PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)i.next();
+         portalObjectMD.create(buildContext, object);
+      }
+
+      //
+      return object;
+   }
+
+   protected abstract PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception;
+
+   /**
+    * Configure common state.
+    *
+    * @param buildContext
+    * @param object
+    * @throws SecurityConfigurationException
+    */
+   private void configure(BuildContext buildContext, PortalObject object) throws SecurityConfigurationException
+   {
+      // Configure properties
+      for (Iterator i = properties.entrySet().iterator(); i.hasNext();)
+      {
+         Map.Entry entry = (Map.Entry)i.next();
+         String name = (String)entry.getKey();
+         String value = (String)entry.getValue();
+         object.setDeclaredProperty(name, value);
+      }
+
+      // Configure listener
+      object.setListener(listener);
+
+      // Configure security
+      SecurityConstraintsMetaData securityConstraints = getSecurityConstraints();
+      if (securityConstraints == null)
+      {
+         if (this instanceof PortalMetaData)
+         {
+            // Default is view recursive
+            securityConstraints = new SecurityConstraintsMetaData();
+            RoleSecurityBinding binding = new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME);
+            securityConstraints.getConstraints().add(binding);
+         }
+      }
+      else
+      {
+         // Skip window configuration
+         if (this instanceof WindowMetaData)
+         {
+            securityConstraints = null;
+            log.warn("Window " + getName() + " has security a " +
+               "configuration but it is not taken in account, portlet instance configuration should be done rather");
+         }
+      }
+
+      //
+      if (securityConstraints != null)
+      {
+         // Apply the constraint
+         PortalObjectContainer poc = buildContext.getContainer();
+         DomainConfigurator domainConfigurator = poc.getAuthorizationDomain().getConfigurator();
+         domainConfigurator.setSecurityBindings(object.getId().toString(PortalObjectId.CANONICAL_FORMAT), securityConstraints.getConstraints());
+      }
+   }
+
+   public static PortalObjectMetaData buildMetaData(ContentHandlerRegistry contentHandlerRegistry, Element portalObjectElt) throws Exception
+   {
+      String type = portalObjectElt.getTagName();
+      PortalObjectMetaData portalObjectMD = null;
+      if ("portal".equals(type))
+      {
+         portalObjectMD = PortalMetaData.buildPortalMetaData(contentHandlerRegistry, portalObjectElt);
+      }
+      else if ("page".equals(type))
+      {
+         portalObjectMD = PageMetaData.buildPageMetaData(contentHandlerRegistry, portalObjectElt);
+      }
+      else if ("window".equals(type))
+      {
+         portalObjectMD = WindowMetaData.buildPortletWindowMetaData(contentHandlerRegistry, portalObjectElt);
+      }
+      else if ("context".equals(type))
+      {
+         portalObjectMD = ContextMetaData.buildContextMetaData(contentHandlerRegistry, portalObjectElt);
+      }
+
+      // Parse common XML stuff
+      if (portalObjectMD != null)
+      {
+         // Add the security constraints
+         Element securityConstraintElt = XML.getUniqueChild(portalObjectElt, "security-constraint", false);
+         if (securityConstraintElt != null)
+         {
+            SecurityConstraintsMetaData securityConstraintsMD = SecurityConstraintsMetaData.buildSecurityConstraintMetaData(securityConstraintElt);
+            portalObjectMD.setSecurityConstraints(securityConstraintsMD);
+         }
+
+         // Configure properties
+         Element propertiesElt = XML.getUniqueChild(portalObjectElt, "properties", false);
+         if (propertiesElt != null)
+         {
+            buildPropertiesMetaData(portalObjectMD, propertiesElt);
+         }
+
+         // Configure listener
+         Element listenerElt = XML.getUniqueChild(portalObjectElt, "listener", false);
+         if (listenerElt != null)
+         {
+            buildListenerMetaData(portalObjectMD, listenerElt);
+         }
+      }
+      return portalObjectMD;
+   }
+
+   public static void buildPropertiesMetaData(PortalObjectMetaData portalObjectMD, Element propertiesElt)
+   {
+      List propertyElts = XML.getChildren(propertiesElt, "property");
+      for (int i = 0; i < propertyElts.size(); i++)
+      {
+         Element propertyElt = (Element)propertyElts.get(i);
+         Element nameElt = XML.getUniqueChild(propertyElt, "name", true);
+         Element valueElt = XML.getUniqueChild(propertyElt, "value", true);
+         String name = XML.asString(nameElt);
+         String value = XML.asString(valueElt);
+
+         // log.debug("Found property " + name + " = " + value);
+         portalObjectMD.getProperties().put(name, value);
+      }
+   }
+
+   public static void buildListenerMetaData(PortalObjectMetaData portalObjectMD, Element listenerElt)
+   {
+      String listener = XML.asString(listenerElt);
+      portalObjectMD.setListener(listener);
+   }
+
+   public String toString()
+   {
+      String name = getClass().getName();
+      int start = name.lastIndexOf(".");
+      int end = name.length() - start;
+      return name.substring(start, end) + "[" + name + "]";
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java (from rev 6000, trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/WindowMetaData.java	2007-01-11 15:35:54 UTC (rev 6000)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * 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.metadata;
+
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.metadata.ContentMetaData;
+import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.common.util.XML;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class WindowMetaData extends PortalObjectMetaData
+{
+
+   /** The window region. */
+   protected String region;
+
+   /** The window order. */
+   protected int order;
+
+   /** The window content. */
+   protected ContentMetaData content;
+
+   /** . */
+   protected ContentType contentType;
+
+   public String getRegion()
+   {
+      return region;
+   }
+
+   public void setRegion(String region)
+   {
+      this.region = region;
+   }
+
+   public int getOrder()
+   {
+      return order;
+   }
+
+   public void setOrder(int order)
+   {
+      this.order = order;
+   }
+
+   public ContentMetaData getContent()
+   {
+      return content;
+   }
+
+   public void setContent(ContentMetaData content)
+   {
+      this.content = content;
+   }
+
+   public ContentType getContentType()
+   {
+      return contentType;
+   }
+
+   public void setContentType(ContentType contentType)
+   {
+      this.contentType = contentType;
+   }
+
+   protected PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception
+   {
+      if (!(parent instanceof Page))
+      {
+         throw new IllegalArgumentException("Not a page");
+      }
+
+      //
+      Window window = ((Page)parent).createWindow(getName(), contentType);
+
+      //
+      window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, region);
+      window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + order);
+
+      //
+      content.configure(window.getContent());
+
+      //
+      return window;
+   }
+
+   public static WindowMetaData buildPortletWindowMetaData(ContentHandlerRegistry registry, Element windowElt) throws Exception
+   {
+      WindowMetaData windowMD = new WindowMetaData();
+
+      //
+      String windowName = XML.asString(XML.getUniqueChild(windowElt, "window-name", true));
+      windowMD.setName(windowName);
+
+      // Get coordinates
+      String region = XML.asString(XML.getUniqueChild(windowElt, "region", true));
+      windowMD.setRegion(region);
+
+      //
+      int height = Integer.parseInt(XML.asString(XML.getUniqueChild(windowElt, "height", true)));
+      windowMD.setOrder(height);
+
+      //
+      ContentType contentType = ContentType.PORTLET;
+      Element contentTypeElt = XML.getUniqueChild(windowElt, "content-type", false);
+      if (contentTypeElt != null)
+      {
+         String value = XML.asString(contentTypeElt);
+         contentType = ContentType.create(value);
+      }
+      windowMD.setContentType(contentType);
+
+      // Build content meta data
+      ContentHandler handler = registry.getHandler(contentType);
+      ContentMetaData contentMD = handler.newMetaData(windowElt);
+      windowMD.setContent(contentMD);
+
+      //
+      return windowMD;
+   }
+
+   public String toString()
+   {
+      return "Window[" + getName() + "]";
+   }
+}


Property changes on: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -28,7 +28,7 @@
 import org.jboss.portal.cms.Command;
 import org.jboss.portal.cms.model.File;
 import org.jboss.portal.cms.util.FileUtil;
-import org.jboss.portal.core.cms.StreamContentCommand;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
 import org.jboss.portal.core.controller.ControllerContext;
 import org.jboss.portal.server.request.URLContext;
 import org.jboss.portal.server.request.URLFormat;

Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -40,8 +40,8 @@
 import org.jboss.portal.cms.security.PermissionManager;
 import org.jboss.portal.cms.util.FileUtil;
 import org.jboss.portal.cms.util.NodeUtil;
-import org.jboss.portal.core.cms.StreamContentCommand;
 import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
 import org.jboss.portal.identity.AnnonymousRole;
 import org.jboss.portal.identity.IdentityException;
 import org.jboss.portal.identity.MembershipModule;
@@ -501,7 +501,7 @@
          rReq.setAttribute("manageRoleSet", manageRoleSet);
          rReq.setAttribute("manageUserSet", manageUserSet);
 
-         //operation to return from the security console 
+         //operation to return from the security console
          rReq.setAttribute("returnOp", returnOp);
 
          if (sConfirm != null)

Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -30,6 +30,8 @@
 import org.jboss.portal.core.model.portal.PortalObjectContainer;
 import org.jboss.portal.core.model.portal.PortalObjectId;
 import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.portlet.content.PortletContent;
+import org.jboss.portal.core.model.content.ContentType;
 import org.jboss.portal.theme.LayoutService;
 import org.jboss.portal.theme.PortalLayout;
 import org.jboss.portal.theme.PortalTheme;
@@ -236,10 +238,14 @@
                   windowName = "" + doWindowNaming();
                }
 
-               Window window = page.createWindow(windowName);
-               window.setInstanceRef(copyInstance[i]);
+               //
+               Window window = page.createWindow(windowName, ContentType.PORTLET);
                window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
                window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+
+               //
+               PortletContent content = (PortletContent)window.getContent();
+               content.setInstanceRef(copyInstance[i]);
             }
          }
          catch (Exception e)

Modified: trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/management/actions/AddWindowAction.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -24,6 +24,8 @@
 
 import org.jboss.portal.core.model.portal.Page;
 import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.portal.portlet.content.PortletContent;
 import org.jboss.portal.core.portlet.management.PortalObjectManagerBean;
 import org.jboss.portal.theme.ThemeConstants;
 
@@ -118,10 +120,14 @@
          String region = (String)vb.getValue(ctx);
          Page page = (Page)pomgr.getSelectedObject();
 
-         Window window = page.createWindow(windowName);
-         window.setInstanceRef(instanceId);
+         //
+         Window window = page.createWindow(windowName, ContentType.PORTLET);
          window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, region);
          window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+
+         //
+         PortletContent content = (PortletContent)window.getContent();
+         content.setInstanceRef(instanceId);
       }
       catch (Exception e)
       {

Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -30,6 +30,8 @@
 import org.jboss.portal.core.model.portal.PortalObject;
 import org.jboss.portal.core.model.portal.Window;
 import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.portal.portlet.content.PortletContent;
 import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl;
 import org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory;
 import org.jboss.portal.test.core.PortalBaseTestCase;
@@ -164,7 +166,7 @@
       assertEquals("bar3", page.getProperty("foo3"));
 
       //
-      Window window = page.createWindow("default");
+      Window window = page.createWindow("default", ContentType.PORTLET);
       assertNotNull(window);
       PortalObjectId windowId = window.getId();
       assertNotNull(windowId);
@@ -270,9 +272,10 @@
       portal.getSupportedModes().add(Mode.VIEW);
       Page page = portal.createPage("default");
       page.setDeclaredProperty("pagename", "pagevalue");
-      Window window = page.createWindow("window");
+      Window window = page.createWindow("window", ContentType.PORTLET);
       window.setDeclaredProperty("windowname", "windowvalue");
-      window.setInstanceRef("instance");
+      PortletContent content = (PortletContent)window.getContent();
+      content.setInstanceRef("instance");
       assertTrue(hibernate.commitTransaction());
 
       //
@@ -291,7 +294,10 @@
       window = page.getWindow("window");
       assertNotNull(window);
       assertEquals("windowvalue", window.getDeclaredProperty("windowname"));
-      assertEquals("instance", window.getInstanceRef());
+      assertEquals(ContentType.PORTLET, window.getContentType());
+      content = (PortletContent)window.getContent();
+      assertNotNull(content);
+      assertEquals("instance", content.getInstanceRef());
       assertTrue(hibernate.commitTransaction());
 
       //

Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml	2007-01-15 23:10:21 UTC (rev 6007)
@@ -363,8 +363,8 @@
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=ContextDispatcher</depends-list-element>
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=ContextTracker</depends-list-element>
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=PortletSessionSynchronization</depends-list-element>
-		 <depends-list-element>portal:service=Interceptor,type=Portlet,name=WindowStates</depends-list-element>
-		 <depends-list-element>portal:service=Interceptor,type=Portlet,name=Bridge</depends-list-element>
+         <depends-list-element>portal:service=Interceptor,type=Portlet,name=WindowStates</depends-list-element>
+         <depends-list-element>portal:service=Interceptor,type=Portlet,name=Bridge</depends-list-element>
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=Modes</depends-list-element>
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=ProducerCache</depends-list-element>
          <depends-list-element>portal:service=Interceptor,type=Portlet,name=Header</depends-list-element>
@@ -598,6 +598,28 @@
       <attribute name="SessionFactoryJNDIName">java:/portal/PortalObjectSessionFactory</attribute>
       <attribute name="CacheNaturalId">true</attribute>
    </mbean>
+   <mbean
+      code="org.jboss.portal.core.model.portal.portlet.content.PortletContentHandler"
+      name="portal:service=ContentHandler,type=portlet"
+      xmbean-dd=""
+      xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+      <xmbean/>
+      <depends
+         optional-attribute-name="Registry"
+         proxy-type="attribute">portal:container=PortalObject</depends>
+      <attribute name="ContentType">portlet</attribute>
+   </mbean>
+   <mbean
+      code="org.jboss.portal.core.cms.content.CMSContentHandler"
+      name="portal:service=ContentHandler,type=cms"
+      xmbean-dd=""
+      xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+      <xmbean/>
+      <depends
+         optional-attribute-name="Registry"
+         proxy-type="attribute">portal:container=PortalObject</depends>
+      <attribute name="ContentType">cms</attribute>
+   </mbean>
 
    <!-- Customization manager -->
    <mbean
@@ -1026,6 +1048,9 @@
       <depends
          optional-attribute-name="PortalObjectContainer"
          proxy-type="attribute">portal:container=PortalObject</depends>
+      <depends
+         optional-attribute-name="ContentHandlerRegistry"
+         proxy-type="attribute">portal:container=PortalObject</depends>
       <attribute name="SetupLocation">conf/data/default-object.xml</attribute>
       <!-- Set to false in clustered mode, otherwise set to true -->
       <attribute name="RegistrationControlledByService">@portal.single@</attribute>

Modified: trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml	2007-01-15 23:10:21 UTC (rev 6007)
@@ -90,27 +90,11 @@
                <height>0</height>
             </window>
             <window>
-               <window-name>DefaultCMSPortletWindow</window-name>
-               <instance-ref>CMSPortletInstance</instance-ref>
+               <window-name>CMSWindow</window-name>
+               <content-type>cms</content-type>
                <region>center</region>
                <height>0</height>
-               <properties>
-                  <!-- use the window renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.windowRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-                  <!-- use the decoration renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.decorationRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-                  <!-- use the portlet renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.portletRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-               </properties>
+               <uri>/default/index.html</uri>
             </window>
             <window>
                <window-name>UserPortletWindow</window-name>
@@ -278,27 +262,11 @@
                <height>0</height>
             </window>
             <window>
-               <window-name>DefaultCMSPortletWindow</window-name>
-               <instance-ref>CMSPortletInstance</instance-ref>
+               <window-name>CMSWindow</window-name>
+               <content-type>cms</content-type>
                <region>center</region>
                <height>0</height>
-               <properties>
-                  <!-- use the window renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.windowRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-                  <!-- use the decoration renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.decorationRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-                  <!-- use the portlet renderer from the emptyRenderer renderSet -->
-                  <property>
-                     <name>theme.portletRendererId</name>
-                     <value>emptyRenderer</value>
-                  </property>
-               </properties>
+               <uri>/default/index.html</uri>
             </window>
             <window>
                <window-name>UserPortletWindow</window-name>

Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java	2007-01-15 21:17:40 UTC (rev 6006)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java	2007-01-15 23:10:21 UTC (rev 6007)
@@ -47,7 +47,7 @@
    private Map actions;
    private final Properties properties;
    private final String headerContent;
-   private final Map windowProperties;
+   private Map windowProperties;
    private final WindowState windowState;
    private final Mode mode;
 
@@ -132,6 +132,11 @@
       return windowProperties;
    }
 
+   public void setWindowProperties(Map windowProperties)
+   {
+      this.windowProperties = windowProperties;
+   }
+
    /**
     * Represents an action that can be triggered.
     * <p/>




More information about the portal-commits mailing list