[portal-commits] JBoss Portal SVN: r9013 - in branches/UIServer: uiserver/src/main/org/jboss/portal/presentation and 5 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Sun Nov 18 15:00:55 EST 2007


Author: julien at jboss.com
Date: 2007-11-18 15:00:55 -0500 (Sun, 18 Nov 2007)
New Revision: 9013

Added:
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java
Removed:
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/entry/
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/entry/PortalEntryPoint.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/entry/EntryPointImpl.java
Modified:
   branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/controller/UIController.java
   branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
   branches/UIServer/uiserver/src/resources/presentation-war/WEB-INF/web.xml
Log:
- remove EntryPoint as it is possible to reuse the existing PortalServlet that will delegate to the UIController which implements RequestController provided by the ControllerFactory

Modified: branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml
===================================================================
--- branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/core-uiserver/src/resources/presentation-sar/META-INF/jboss-service.xml	2007-11-18 20:00:55 UTC (rev 9013)
@@ -43,16 +43,6 @@
          proxy-type="attribute">portal:service=Controller,type=Presentation</depends>
    </mbean>
    <mbean
-       code="org.jboss.portal.presentation.impl.entry.EntryPointImpl"
-       name="portal:service=EntryPoint"
-       xmbean-dd=""
-       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
-       <xmbean/>
-       <depends optional-attribute-name="InterceptorStackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Server</depends>
-       <depends optional-attribute-name="ControllerFactory" proxy-type="attribute">portal:service=ControllerFactory,type=Presentation</depends>
-       <depends optional-attribute-name="PortalServer" proxy-type="attribute">portal:service=Server</depends>
-   </mbean>
-   <mbean
       code="org.jboss.portal.core.presentation.server.PresentationServerImpl"
       name="portal:service=PresentationServer"
       xmbean-dd=""

Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/controller/UIController.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/controller/UIController.java	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/controller/UIController.java	2007-11-18 20:00:55 UTC (rev 9013)
@@ -97,7 +97,7 @@
          /**
           * TODO: move this functionality to another component like a UIPresenter etc
           */
-         ServerAction serverAction = this.getServerAction(presentationContext);
+         ServerAction serverAction = this.getServerAction(presentationContext, invocation);
          
          ProcessorRequest processorRequest = new ProcessorRequest(serverAction);         
          ProcessorResponse processorResponse = this.presentationServer.getProcessor().process(presentationContext,
@@ -105,7 +105,7 @@
                   
          //Process the response from the Processor
          ServerResponse serverResponse = processorResponse.getResponse();
-         this.handle(presentationContext, serverResponse);
+         this.handle(presentationContext, serverResponse, invocation);
       }
       catch(Exception e)
       {
@@ -118,11 +118,11 @@
     * @param serverResponse
     * @throws ServerException
     */
-   private void handle(PresentationContext presentationContext, ServerResponse serverResponse) throws ServerException
+   private void handle(PresentationContext presentationContext, ServerResponse serverResponse, ServerInvocation invocation) throws ServerException
    {
       try
       {
-         HttpServletResponse response = presentationContext.getInvocation().getServerContext().getClientResponse();
+         HttpServletResponse response = invocation.getServerContext().getClientResponse();
          if(serverResponse instanceof ShowUIObjectResponse)
          {
             ShowUIObjectResponse show = (ShowUIObjectResponse)serverResponse;
@@ -205,11 +205,10 @@
    /**
     * 
     */
-   private ServerAction getServerAction(PresentationContext presentationContext)
+   private ServerAction getServerAction(PresentationContext presentationContext, ServerInvocation invocation)
    {
       ServerAction serverAction = null;
       
-      ServerInvocation invocation = presentationContext.getInvocation();
       ServerInvocationContext invocationContext = invocation.getServerContext();
       HttpServletRequest request = invocationContext.getClientRequest();
             
@@ -355,4 +354,186 @@
       clientConnection.write(buffer.toString());
       clientConnection.flush();
    }
+
+   // ---------All these are just helper methods for the prototype-----------------------------------------------------------------------------------------------
+   //----It containts mostly hard coded logic for the prototype-------------------------------------------------------------------------------------------------
+   /**
+    *
+    */
+   /*private Object[] getFlexibleGridLayoutManager(Page pageResult)
+   {
+
+      Page page = new Page();
+      Container header = new Container("header");
+      Container leftPanel = new Container("leftPanel");
+      Container mainPanel = new Container("mainPanel");
+      Window headerTabsWindow = new Window("header-tabs-window");
+      Window menuWindow = new Window("menu-window");
+      Window leftPanelWindow1 = new Window("left-panel-window1");
+      Window leftPanelWindow2 = new Window("left-panel-window2");
+      Window mainPanelWindow = new Window("main-panel-window");
+      header.addComponent(headerTabsWindow);
+      header.addComponent(menuWindow);
+      leftPanel.addComponent(leftPanelWindow1);
+      leftPanel.addComponent(leftPanelWindow2);
+      mainPanel.addComponent(mainPanelWindow);
+
+      //Setup the Grid for headerTabs container
+      page.addContainer(header);
+      FlexibleGrid headerGrid = this.getGrid("header", 1, 2);
+      FlexibleGridConstraints[] headerTabConstraints  = { this.getConstraints("header-tabs-window", "100", 0, 0, 10, 0, 0, 0),
+      this.getConstraints("menu-window", "100", 0, 0, 0, 0, 0, 1) };
+      headerGrid.setConstraints(headerTabConstraints);
+
+      //Setup the Grid for left panel container
+      page.addContainer(leftPanel);
+      FlexibleGrid leftPanelGrid = this.getGrid("leftPanel", 2, 1);
+      FlexibleGridConstraints[] leftPanelConstraints  = { this.getConstraints("left-panel-window1", "75", 0, 0, 0, 0, 0, 0),
+      this.getConstraints("left-panel-window2", "75", 0, 0, 0, 0, 1, 0) };
+      leftPanelGrid.setConstraints(leftPanelConstraints);
+
+      //Setup the Grid for main panel container
+      page.addContainer(mainPanel);
+      FlexibleGrid mainPanelGrid = this.getGrid("mainPanel", 1, 1);
+      FlexibleGridConstraints[] mainPanelConstraints  = { this.getConstraints("main-panel-window", "100", 0, 0, 0, 0, 0, 0) };
+      mainPanelGrid.setConstraints(mainPanelConstraints);
+
+      //Setup the FlexibleGrid Layout Manager with the different grids
+      FlexibleGrid[] row1 = { headerGrid };
+      FlexibleGrid[] row2 = { leftPanelGrid, mainPanelGrid };
+      FlexibleGridLayoutManager layoutManager = new FlexibleGridLayoutManager();
+      layoutManager.addRowOfGrids(row1);
+      layoutManager.addRowOfGrids(row2);
+
+      //Populate the grid windows with proper content
+      List windows = pageResult.getWindows();
+      int counter = 0;
+      for(Iterator itr=windows.iterator();itr.hasNext();)
+      {
+         Window result = (Window)itr.next();
+
+         switch(counter)
+         {
+            case 0:
+               leftPanelWindow1.setContent(result.getContent());
+            break;
+
+            case 1:
+               leftPanelWindow2.setContent(result.getContent());
+            break;
+
+            case 2:
+               mainPanelWindow.setContent(result.getContent());
+            break;
+
+            case 3:
+               menuWindow.setContent(result.getContent());
+            break;
+
+            case 4:
+               headerTabsWindow.setContent(result.getContent());
+            break;
+         }
+
+         counter++;
+      }
+
+      return new Object[]{page, layoutManager};
+   }*/
+
+
+   /**
+    *
+    * @param containerId
+    * @param rows
+    * @param columns
+    * @return
+    */
+   /*private FlexibleGrid getGrid(String containerId,int rows, int columns)
+   {
+      FlexibleGrid grid = new FlexibleGrid(containerId);
+      grid.setRows(rows);
+      grid.setColumns(columns);
+      return grid;
+   }*/
+
+   /**
+    *
+    * @param componentId
+    * @param widthPercentage
+    * @param top
+    * @param bottom
+    * @param left
+    * @param right
+    */
+   /*private FlexibleGridConstraints getConstraints(String componentId, String widthPercentage, int top, int bottom, int left, int right, int row, int column)
+   {
+      FlexibleGridConstraints constraints = new FlexibleGridConstraints();
+      constraints.setComponentId(componentId);
+      constraints.setWidthPercentage(widthPercentage);
+      constraints.setRow(row);
+      constraints.setColumn(column);
+      constraints.setTop(top);
+      constraints.setBottom(bottom);
+      constraints.setLeft(left);
+      constraints.setRight(right);
+      return constraints;
+   }*/
+
+   /**
+    *
+    * @param pageResult
+    * @return
+    */
+   /*private Object[] getRegionBasedLayoutManager(Page pageResult)
+   {
+      Page page = new Page();
+      Container left = new Container("left");
+      Container center = new Container("center");
+      page.addContainer(left);
+      page.addContainer(center);
+
+      //Populate the grid windows with proper content
+      List windows = pageResult.getWindows();
+      int counter = 0;
+      for(Iterator itr=windows.iterator();itr.hasNext();)
+      {
+         Window result = (Window)itr.next();
+         Window uiWindow = new Window(result.getId());
+         uiWindow.setContent(result.getContent());
+         switch(counter)
+         {
+            case 0:
+               left.addComponent(uiWindow);
+            break;
+
+            case 1:
+               left.addComponent(uiWindow);
+            break;
+
+            case 2:
+               center.addComponent(uiWindow);
+            break;
+
+            case 3:
+               center.addComponent(uiWindow);
+            break;
+
+            case 4:
+               left.addComponent(uiWindow);
+            break;
+         }
+
+         counter++;
+      }
+
+      RegionLayoutManager layoutManager = new RegionLayoutManager();
+      RegionConstraints leftConstraints = new RegionConstraints("left", RegionConstraints.LEFT);
+      RegionConstraints centerConstraints = new RegionConstraints("center", RegionConstraints.CENTER);
+      layoutManager.addRegionConstraints(leftConstraints);
+      layoutManager.addRegionConstraints(centerConstraints);
+
+      return new Object[]{page, layoutManager};
+   }*/
+
 }

Copied: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java (from rev 9008, branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/entry/GWTClientFilter.java)
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java	                        (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/GWTClientFilter.java	2007-11-18 20:00:55 UTC (rev 9013)
@@ -0,0 +1,154 @@
+/******************************************************************************
+ * 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.presentation.impl.ajax.entry;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This filter is activated or deactivated depending on whether the Portal needs to runs in Ajax mode or Classic Html mode
+ * 
+ * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
+ *
+ */
+public class GWTClientFilter implements Filter
+{
+   /**
+    * 
+    */
+   public void init(FilterConfig arg0) throws ServletException
+   {  
+   }
+   
+   /**
+    * 
+    */
+   public void destroy()
+   {  
+   }
+
+   /**
+    * 
+    */
+   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
+   { 
+      HttpServletRequest request = (HttpServletRequest)servletRequest;
+      HttpServletResponse response = (HttpServletResponse)servletResponse;
+      String contextPath = request.getContextPath();
+      
+      //Extract the resource that is being accessed
+      String resource = request.getRequestURI().replaceFirst(contextPath, "");
+      while(resource.startsWith("/"))
+      {
+         if(resource.length() > 1)
+         {
+            resource = resource.substring(1);
+         }
+         else
+         {
+            resource = "";
+         }
+      }
+      
+      if(resource == null || resource.trim().length() == 0)
+      {
+         response.sendRedirect("index.html");
+         return;
+      }
+      
+      //Now make sure the resource requested is a GWT resource
+      if(   resource.equals("index.html") ||
+            resource.equals("portal.css") ||
+            resource.equals("mygwt-all.css") ||
+            resource.equals("mygwt-all-gray.css") ||
+            resource.equals("gwt.js") ||
+            resource.equals("prototype.js") ||
+            resource.contains(".cache.") ||
+            resource.contains(".nocache.") ||
+            resource.contains(".gwt.rpc") ||
+            resource.contains("images/default") ||
+            resource.contains("images/gray")
+      )
+      {
+         byte[] gwtResource = this.readContent(resource);
+         response.getOutputStream().write(gwtResource);
+         response.getOutputStream().flush();
+         return;
+      }
+   }
+   
+   /**
+    * 
+    * @param path
+    * @return
+    */
+   private byte[] readContent(String path)
+   {
+      byte[] content = null;
+        
+      InputStream is = null;
+      ByteArrayOutputStream bos = null;
+      try
+      {
+         bos = new ByteArrayOutputStream();
+         is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+         int bytesRead = 0;
+         byte[] data = new byte[1024];
+         while((bytesRead=is.read(data)) != -1)
+         {
+            byte[] cour = new byte[bytesRead];
+            System.arraycopy(data, 0, cour, 0, bytesRead);
+            bos.write(cour);
+            bos.flush();
+         }         
+      }
+      catch(Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+      finally
+      {
+         if(is != null)
+         {
+            try{is.close();}catch(Exception e){}
+         }
+         if(bos != null)
+         {
+            content = bos.toByteArray();
+            try{bos.close();}catch(Exception e){}
+         }
+      }
+      
+      return content;
+   }
+}

Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java	2007-11-18 20:00:55 UTC (rev 9013)
@@ -33,7 +33,6 @@
 import org.jboss.portal.presentation.ajax.client.protocol.Page;
 import org.jboss.portal.presentation.ajax.client.protocol.Window;
 import org.jboss.portal.presentation.server.ProcessorResponse;
-import org.jboss.portal.presentation.entry.EntryPoint;
 
 import com.google.gwt.user.client.rpc.SerializationException;
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -45,8 +44,7 @@
  * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
  * 
  */
-public class PortalEntryPoint extends RemoteServiceServlet implements 
-PortalRPC
+public class PortalEntryPoint extends RemoteServiceServlet implements PortalRPC
 {
    /** The logger. */
    private Logger log = Logger.getLogger(getClass());
@@ -54,25 +52,25 @@
    /**
     * 
     */
-   private EntryPoint entryPoint = null;
+//   private EntryPoint entryPoint = null;
 
    /** Configure the as default servlet. */
    public void init() throws ServletException
    {
-      try
-      {
-         MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
-         this.entryPoint = (EntryPoint) MBeanProxy.get(EntryPoint.class, new ObjectName(
-               this.getInitParameter("entryPointServiceName")),
-               mbeanServer);
-      }
-      catch (Exception e)
-      {
-         this.entryPoint = null;
-         String msg = "Portal Entry Point could not be created";
-         log.error(msg, e);
-         throw new UnavailableException(msg);
-      }
+//      try
+//      {
+//         MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+//         this.entryPoint = (EntryPoint) MBeanProxy.get(EntryPoint.class, new ObjectName(
+//               this.getInitParameter("entryPointServiceName")),
+//               mbeanServer);
+//      }
+//      catch (Exception e)
+//      {
+//         this.entryPoint = null;
+//         String msg = "Portal Entry Point could not be created";
+//         log.error(msg, e);
+//         throw new UnavailableException(msg);
+//      }
    }
    
    /**
@@ -174,6 +172,7 @@
     */
    private void callPortalServer() throws Exception
    {
+/*
       HttpServletRequest req = this.getThreadLocalRequest();
       HttpServletResponse resp = this.getThreadLocalResponse();
       String requestURI = req.getRequestURI();
@@ -218,5 +217,6 @@
       
       InterceptorStackFactory stack = this.entryPoint.getInterceptorStackFactory();      
       invocation.invoke(stack.getInterceptorStack());
+*/
    }
 }

Deleted: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/entry/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/entry/PortalEntryPoint.java	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/entry/PortalEntryPoint.java	2007-11-18 20:00:55 UTC (rev 9013)
@@ -1,563 +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.presentation.impl.classic.entry;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.UnavailableException;
-
-import org.apache.log4j.Logger;
-import org.jboss.mx.util.MBeanProxy;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.portal.common.http.QueryStringParser;
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.common.net.URLTools;
-import org.jboss.portal.common.util.Exceptions;
-import org.jboss.portal.server.PortalConstants;
-import org.jboss.portal.server.RequestController;
-import org.jboss.portal.server.RequestControllerDispatcher;
-import org.jboss.portal.server.RequestControllerFactory;
-import org.jboss.portal.server.Server;
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.ServerInvocationContext;
-import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.server.ServerResponse;
-import org.jboss.portal.server.impl.ServerInvocationContextImpl;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.presentation.entry.EntryPoint;
-
-/**
- * The Portal Server Entry Point for classic html mode
- * 
- * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
- *
- */
-public class PortalEntryPoint extends HttpServlet
-{
-   /**
-    * 
-    */
-   private Logger log = Logger.getLogger(getClass());
-   
-   /** . */
-   private static final int GET_METHOD = 0;
-
-   /** . */
-   private static final int POST_METHOD = 1;
-
-   /** Describes a default servlet mapping. */
-   private static final int DEFAULT_SERVLET_MAPPING = 0;
-
-   /** Describes a root path mapping. */
-   private static final int ROOT_PATH_MAPPING = 1;
-
-   /** Describes a path mapping. */
-   private static final int PATH_MAPPING = 2;
-   
-   /** Are we or not the default servlet ? */
-   private boolean asDefaultServlet = false;
-   
-   /**
-    * 
-    */
-   private EntryPoint entryPoint = null;
-   
-   /** Configure the as default servlet. */
-   public void init() throws ServletException
-   {
-      asDefaultServlet = getAsDefaultServletInitValue();
-      try
-      {
-         MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
-         this.entryPoint = (EntryPoint) MBeanProxy.get(EntryPoint.class, new ObjectName(
-               this.getInitParameter("entryPointServiceName")),
-               mbeanServer);
-      }
-      catch (Exception e)
-      {
-         this.entryPoint = null;
-         String msg = "Portal Entry Point could not be created";
-         log.error(msg, e);
-         throw new UnavailableException(msg);
-      }
-   }
-   
-   /**
-    * 
-    */
-   protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
-   {
-      //
-      String servletPath = req.getServletPath();
-      String requestURI = req.getRequestURI();
-      String contextPath = req.getContextPath();
-      
-      String resource = req.getRequestURI().replaceFirst(contextPath, "");
-      while(resource.startsWith("/"))
-      {
-         if(resource.length() > 1)
-         {
-            resource = resource.substring(1);
-         }
-         else
-         {
-            resource = "";
-         }
-      }
-      
-      if(resource == null || resource.trim().length() == 0)
-      {
-         resp.sendRedirect("index.html");
-         return;
-      }
-      
-      int method;
-      if ("GET".equals(req.getMethod()))
-      {
-         method = GET_METHOD;
-      }
-      else if ("POST".equals(req.getMethod()))
-      {
-         method = POST_METHOD;
-      }
-      else
-      {
-         throw new ServletException();
-      }
-
-      // Compute the media type in the content type
-      String mediaType = this.entryPoint.retrieveMediaType(req.getContentType());
-
-      // Only affect the charset encoding if the servlet container will decode the request
-      if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
-      {
-         // Now we must ensure that we have either an equals or a trailing space after the media-type
-         String characterEncoding = req.getCharacterEncoding();
-         if (characterEncoding == null)
-         {
-            // Set out charset for the portal request
-            req.setCharacterEncoding(PortalConstants.UTF_8.name());
-         }
-         else
-         {
-            Charset charset = Charset.forName(characterEncoding);
-            if (!PortalConstants.UTF_8.equals(charset))
-            {
-               throw new ServletException("Unaccepted charset " + characterEncoding);
-            }
-         }
-      }
-
-      // Determine the mapping we have
-      int mapping = DEFAULT_SERVLET_MAPPING;
-      if (!asDefaultServlet)
-      {
-         if (servletPath.length() == 0)
-         {
-            mapping = ROOT_PATH_MAPPING;
-         }
-         else
-         {
-            mapping = PATH_MAPPING;
-         }
-      }
-
-      // Determine the host for this request
-      String portalHost = req.getServerName();
-
-      // Determine the request path
-      String portalRequestPath = null;
-      String portalContextPath = null;
-      switch (mapping)
-      {
-         case DEFAULT_SERVLET_MAPPING:
-            portalRequestPath = requestURI.substring(contextPath.length());
-            portalContextPath = requestURI.substring(0, contextPath.length());
-            break;
-         case ROOT_PATH_MAPPING:
-            portalRequestPath = requestURI.substring(contextPath.length());
-            portalContextPath = requestURI.substring(0, contextPath.length());
-            break;
-         case PATH_MAPPING:
-            portalRequestPath = requestURI.substring(contextPath.length() + servletPath.length());
-            portalContextPath = requestURI.substring(0, contextPath.length() + servletPath.length());
-            break;
-      }
-
-      // Apply the url decoding
-      portalRequestPath = URLTools.decodeXWWWFormURL(portalRequestPath);
-      portalContextPath = URLTools.decodeXWWWFormURL(portalContextPath);
-
-      //
-      URLContext urlContext = URLContext.newInstance(req.isSecure(), req.getRemoteUser() != null);
-
-      // ***************
-      // ***************
-      // ***************
-      // ***************
-
-      // Parse the query string to have the get parameters
-      // The resulting map has its parameters decoded from the x-www-form-url encoding
-      Map queryParameterMap = Collections.EMPTY_MAP;
-      String queryString = req.getQueryString();
-      if (queryString != null)
-      {
-         queryParameterMap = QueryStringParser.parseQueryString(queryString);
-      }
-
-      //
-      Map bodyParameterMap = null;
-      if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
-      {
-         bodyParameterMap = Collections.EMPTY_MAP;
-         for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
-         {
-            Map.Entry entry = (Map.Entry)i.next();
-
-            // Get param name
-            String paramName = (String)entry.getKey();
-
-            // Values that are aggregated from the query string and the body
-            String[] paramValues = (String[])entry.getValue();
-
-            // Values decoded from the query string
-            String[] queryValues = (String[])queryParameterMap.get(paramName);
-            if (queryValues != null)
-            {
-               int bodyValuesLength = paramValues.length - queryValues.length;
-               if (bodyValuesLength > 0)
-               {
-                  String[] bodyValues = new String[bodyValuesLength];
-                  System.arraycopy(paramValues, queryValues.length, bodyValues, 0, bodyValuesLength);
-                  if (bodyParameterMap.isEmpty())
-                  {
-                     bodyParameterMap = new HashMap();
-                  }
-                  bodyParameterMap.put(paramName, bodyValues);
-               }
-            }
-            else
-            {
-               if (bodyParameterMap.isEmpty())
-               {
-                  bodyParameterMap = new HashMap();
-               }
-               bodyParameterMap.put(paramName, paramValues);
-            }
-         }
-
-         // Make the map unmodifiable
-         bodyParameterMap = bodyParameterMap.isEmpty() ? bodyParameterMap : Collections.unmodifiableMap(bodyParameterMap);
-      }
-
-      // ***************
-      // ***************
-      // ***************
-      // ***************
-
-      //
-      Server server = this.entryPoint.getPortalServer();
-
-      //
-      ServerInvocationContext invocationCtx = new ServerInvocationContextImpl(
-         req,
-         resp,
-         portalHost,
-         portalRequestPath,
-         portalContextPath,
-         queryParameterMap,
-         bodyParameterMap,
-         urlContext,
-         mediaType);
-
-      //
-      ServerRequest request = new ServerRequest(invocationCtx);
-      request.setServer(server);
-
-      //
-      ServerResponse response = new ServerResponse(request, invocationCtx);
-
-      //
-      ServerInvocation invocation = new ServerInvocation(invocationCtx);
-      invocation.setRequest(request);
-      invocation.setResponse(response);
-
-      //
-      RequestControllerFactory controllerFactory = this.entryPoint.getControllerFactory();
-      RequestController controller = controllerFactory.createRequestController(invocation);
-      invocation.setHandler(new RequestControllerDispatcher(controller));
-
-      //
-      try
-      {
-         InterceptorStackFactory stack = this.entryPoint.getInterceptorStackFactory();
-         invocation.invoke(stack.getInterceptorStack());          
-      }
-      catch (ServerException e)
-      {
-         log.error("Server exception", e);
-         Throwable nested = Exceptions.unwrap(e);
-         throw new ServletException(nested);
-      }
-      catch (InvocationException e)
-      {
-         log.error("Invocation exception", e);
-         Throwable nested = Exceptions.unwrap(e);
-         throw new ServletException(nested);
-      }
-      catch (ServletException e)
-      {
-         throw e;
-      }
-      catch (IOException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         log.error("Unexpected exception", e);
-         Throwable nested = Exceptions.unwrap(e);
-         throw new ServletException(nested);
-      }
-   } 
-   
-   /**
-    * Return the value for the servlet mapping. This implementation get the
-    * value from an init parameter of the servlet called <b>asDefaultServlet</b>
-    */
-   private boolean getAsDefaultServletInitValue()
-   {
-      ServletConfig config = getServletConfig();
-      String value = config.getInitParameter("asDefaultServlet");
-      if ("true".equalsIgnoreCase(value))
-      {
-         log.debug("Servlet loaded as default servlet mapping");
-         return true;
-      }
-      else if ("false".equalsIgnoreCase(value))
-      {
-         log.debug("Servlet loaded as path mapping servlet");
-         return false;
-      }
-      else
-      {
-         log.warn("Servlet mapping cannot be determined with init parameter value="
-                     + value);
-         return false;
-      }
-   }   
-   // ---------All these are just helper methods for the prototype-----------------------------------------------------------------------------------------------
-   //----It containts mostly hard coded logic for the prototype-------------------------------------------------------------------------------------------------      
-   /**
-    * 
-    */
-   /*private Object[] getFlexibleGridLayoutManager(Page pageResult)
-   {
-      
-      Page page = new Page();
-      Container header = new Container("header");
-      Container leftPanel = new Container("leftPanel");
-      Container mainPanel = new Container("mainPanel");
-      Window headerTabsWindow = new Window("header-tabs-window");
-      Window menuWindow = new Window("menu-window");
-      Window leftPanelWindow1 = new Window("left-panel-window1");
-      Window leftPanelWindow2 = new Window("left-panel-window2");
-      Window mainPanelWindow = new Window("main-panel-window");
-      header.addComponent(headerTabsWindow);
-      header.addComponent(menuWindow);
-      leftPanel.addComponent(leftPanelWindow1);
-      leftPanel.addComponent(leftPanelWindow2);
-      mainPanel.addComponent(mainPanelWindow);
-            
-      //Setup the Grid for headerTabs container
-      page.addContainer(header);
-      FlexibleGrid headerGrid = this.getGrid("header", 1, 2);
-      FlexibleGridConstraints[] headerTabConstraints  = { this.getConstraints("header-tabs-window", "100", 0, 0, 10, 0, 0, 0),
-      this.getConstraints("menu-window", "100", 0, 0, 0, 0, 0, 1) };
-      headerGrid.setConstraints(headerTabConstraints);      
-      
-      //Setup the Grid for left panel container
-      page.addContainer(leftPanel);
-      FlexibleGrid leftPanelGrid = this.getGrid("leftPanel", 2, 1);
-      FlexibleGridConstraints[] leftPanelConstraints  = { this.getConstraints("left-panel-window1", "75", 0, 0, 0, 0, 0, 0), 
-      this.getConstraints("left-panel-window2", "75", 0, 0, 0, 0, 1, 0) };      
-      leftPanelGrid.setConstraints(leftPanelConstraints);
-      
-      //Setup the Grid for main panel container
-      page.addContainer(mainPanel);
-      FlexibleGrid mainPanelGrid = this.getGrid("mainPanel", 1, 1);
-      FlexibleGridConstraints[] mainPanelConstraints  = { this.getConstraints("main-panel-window", "100", 0, 0, 0, 0, 0, 0) };
-      mainPanelGrid.setConstraints(mainPanelConstraints);
-      
-      //Setup the FlexibleGrid Layout Manager with the different grids
-      FlexibleGrid[] row1 = { headerGrid };
-      FlexibleGrid[] row2 = { leftPanelGrid, mainPanelGrid };
-      FlexibleGridLayoutManager layoutManager = new FlexibleGridLayoutManager();
-      layoutManager.addRowOfGrids(row1);
-      layoutManager.addRowOfGrids(row2);
-            
-      //Populate the grid windows with proper content      
-      List windows = pageResult.getWindows();
-      int counter = 0;
-      for(Iterator itr=windows.iterator();itr.hasNext();)
-      {
-         Window result = (Window)itr.next();
-         
-         switch(counter)
-         {
-            case 0:
-               leftPanelWindow1.setContent(result.getContent());
-            break;
-            
-            case 1:
-               leftPanelWindow2.setContent(result.getContent());
-            break;
-               
-            case 2:
-               mainPanelWindow.setContent(result.getContent());
-            break;
-               
-            case 3:
-               menuWindow.setContent(result.getContent());
-            break;
-               
-            case 4:
-               headerTabsWindow.setContent(result.getContent());
-            break;
-         }
-         
-         counter++;         
-      }
-      
-      return new Object[]{page, layoutManager};
-   }*/
-      
-   
-   /**
-    * 
-    * @param containerId
-    * @param rows
-    * @param columns
-    * @return
-    */
-   /*private FlexibleGrid getGrid(String containerId,int rows, int columns)
-   {
-      FlexibleGrid grid = new FlexibleGrid(containerId);
-      grid.setRows(rows);
-      grid.setColumns(columns);
-      return grid;
-   }*/
-   
-   /**
-    * 
-    * @param componentId
-    * @param widthPercentage
-    * @param top
-    * @param bottom
-    * @param left
-    * @param right
-    */
-   /*private FlexibleGridConstraints getConstraints(String componentId, String widthPercentage, int top, int bottom, int left, int right, int row, int column)
-   {
-      FlexibleGridConstraints constraints = new FlexibleGridConstraints();
-      constraints.setComponentId(componentId);
-      constraints.setWidthPercentage(widthPercentage);
-      constraints.setRow(row);
-      constraints.setColumn(column);
-      constraints.setTop(top);
-      constraints.setBottom(bottom);
-      constraints.setLeft(left);
-      constraints.setRight(right);
-      return constraints;
-   }*/
-   
-   /**
-    * 
-    * @param pageResult
-    * @return
-    */
-   /*private Object[] getRegionBasedLayoutManager(Page pageResult)
-   {
-      Page page = new Page();
-      Container left = new Container("left");
-      Container center = new Container("center");
-      page.addContainer(left);
-      page.addContainer(center);
-            
-      //Populate the grid windows with proper content      
-      List windows = pageResult.getWindows();
-      int counter = 0;
-      for(Iterator itr=windows.iterator();itr.hasNext();)
-      {
-         Window result = (Window)itr.next();
-         Window uiWindow = new Window(result.getId());
-         uiWindow.setContent(result.getContent());
-         switch(counter)
-         {
-            case 0:
-               left.addComponent(uiWindow);
-            break;
-            
-            case 1:
-               left.addComponent(uiWindow);
-            break;
-               
-            case 2:
-               center.addComponent(uiWindow);
-            break;
-               
-            case 3:
-               center.addComponent(uiWindow);
-            break;
-               
-            case 4:
-               left.addComponent(uiWindow);
-            break;
-         }
-         
-         counter++;         
-      }
-      
-      RegionLayoutManager layoutManager = new RegionLayoutManager();
-      RegionConstraints leftConstraints = new RegionConstraints("left", RegionConstraints.LEFT);
-      RegionConstraints centerConstraints = new RegionConstraints("center", RegionConstraints.CENTER);
-      layoutManager.addRegionConstraints(leftConstraints);
-      layoutManager.addRegionConstraints(centerConstraints);
-      
-      return new Object[]{page, layoutManager};
-   }*/
-}

Deleted: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/entry/EntryPointImpl.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/entry/EntryPointImpl.java	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/entry/EntryPointImpl.java	2007-11-18 20:00:55 UTC (rev 9013)
@@ -1,138 +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.presentation.impl.entry;
-
-import org.jboss.portal.common.invocation.InterceptorStackFactory;
-import org.jboss.portal.server.RequestControllerFactory;
-import org.jboss.portal.server.Server;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.presentation.entry.EntryPoint;
-
-/**
- * Implementation of an Entry Point Utility
- * 
- * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
- *
- */
-public class EntryPointImpl extends AbstractJBossService implements EntryPoint
-{
-   /** The interceptor stack. */
-   private InterceptorStackFactory interceptorStackFactory = null;
-
-   /** The controller for this servlet. */
-   private RequestControllerFactory controllerFactory = null;
-   
-   /**
-    * 
-    */
-   private Server portalServer = null;
-
-         
-   /**
-    * 
-    * @return
-    */
-   public RequestControllerFactory getControllerFactory()
-   {
-      return controllerFactory;
-   }
-
-
-   /**
-    * 
-    * @param controllerFactory
-    */
-   public void setControllerFactory(RequestControllerFactory controllerFactory)
-   {
-      this.controllerFactory = controllerFactory;
-   }
-
-   
-   /**
-    * 
-    * @return
-    */
-   public InterceptorStackFactory getInterceptorStackFactory()
-   {
-      return interceptorStackFactory;
-   }
-
-
-   /**
-    * 
-    * @param interceptorStackFactory
-    */
-   public void setInterceptorStackFactory(
-         InterceptorStackFactory interceptorStackFactory)
-   {
-      this.interceptorStackFactory = interceptorStackFactory;
-   }
-   
-   /**
-    * 
-    * @return
-    */
-   public Server getPortalServer()
-   {
-      return portalServer;
-   }
-
-
-   /**
-    * 
-    * @param portalServer
-    */
-   public void setPortalServer(Server portalServer)
-   {
-      this.portalServer = portalServer;
-   }
-
-
-   /**
-    * 
-    * @param contentType
-    * @return
-    */
-   public String retrieveMediaType(String contentType)
-   {
-      String mediaType = contentType;
-
-      //
-      if (mediaType != null)
-      {
-         // Remove any parameters
-         int index = mediaType.indexOf(';');
-         if (index != -1)
-         {
-            mediaType = contentType.substring(0, index);
-         }
-
-         // Trim
-         mediaType = mediaType.trim();
-
-         // Media type matching is case insensitive, so we convert to lower case
-         mediaType = mediaType.toLowerCase();
-      }
-      return mediaType;
-   }
-}

Modified: branches/UIServer/uiserver/src/resources/presentation-war/WEB-INF/web.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/presentation-war/WEB-INF/web.xml	2007-11-18 19:46:46 UTC (rev 9012)
+++ branches/UIServer/uiserver/src/resources/presentation-war/WEB-INF/web.xml	2007-11-18 20:00:55 UTC (rev 9013)
@@ -40,38 +40,70 @@
 
    <!-- The portal servlet is the main entrance point -->
    <servlet>
-      <servlet-name>PortalEntryPoint</servlet-name>
-      <servlet-class>org.jboss.portal.presentation.impl.classic.entry.PortalEntryPoint</servlet-class>
+      <servlet-name>PortalServletWithPathMapping</servlet-name>
+      <servlet-class>org.jboss.portal.server.servlet.PortalServlet</servlet-class>
       <init-param>
          <param-name>asDefaultServlet</param-name>
          <param-value>false</param-value>
          <description>The servlet needs to know wether it is set as a default servlet or not</description>
       </init-param>
       <init-param>
-         <param-name>entryPointServiceName</param-name>
-         <param-value>portal:service=EntryPoint</param-value>
-         <description>Entry Point Service</description>
+         <param-name>controllerFactoryName</param-name>
+         <param-value>portal:service=ControllerFactory,type=Presentation</param-value>
+         <description>The request controller factory for the portal servlet</description>
       </init-param>
-      <load-on-startup>0</load-on-startup>      
-   </servlet>   
+      <load-on-startup>0</load-on-startup>
+      <security-role-ref>
+        <role-name>Authenticated</role-name>
+        <role-link>Authenticated</role-link>
+      </security-role-ref>
+   </servlet>
+
+   <!-- The portal servlet is the main entrance point -->
+   <servlet>
+      <servlet-name>PortalServletWithDefaultServletMapping</servlet-name>
+      <servlet-class>org.jboss.portal.server.servlet.PortalServlet</servlet-class>
+      <init-param>
+         <param-name>asDefaultServlet</param-name>
+         <param-value>true</param-value>
+         <description>The servlet needs to know wether it is set as a default servlet or not</description>
+      </init-param>
+      <init-param>
+         <param-name>controllerFactoryName</param-name>
+         <param-value>portal:service=ControllerFactory,type=Presentation</param-value>
+         <description>The request controller factory for the portal servlet</description>
+      </init-param>
+      <load-on-startup>0</load-on-startup>
+      <security-role-ref>
+        <role-name>Authenticated</role-name>
+        <role-link>Authenticated</role-link>
+      </security-role-ref>
+   </servlet>
+
+   <!-- Provide access to unauthenticated users -->
    <servlet-mapping>
-      <servlet-name>PortalEntryPoint</servlet-name>
+      <servlet-name>PortalServletWithPathMapping</servlet-name>
       <url-pattern>/*</url-pattern>
    </servlet-mapping>
+
+   <!-- Provide secure access to unauthenticated users -->
    <servlet-mapping>
-      <servlet-name>PortalEntryPoint</servlet-name>
+      <servlet-name>PortalServletWithPathMapping</servlet-name>
       <url-pattern>/sec/*</url-pattern>
    </servlet-mapping>
+
+   <!-- Provide access to authenticated users -->
    <servlet-mapping>
-      <servlet-name>PortalEntryPoint</servlet-name>
+      <servlet-name>PortalServletWithPathMapping</servlet-name>
       <url-pattern>/auth/*</url-pattern>
    </servlet-mapping>
+
+   <!-- Provide secure access to authenticated users -->
    <servlet-mapping>
-      <servlet-name>PortalEntryPoint</servlet-name>
+      <servlet-name>PortalServletWithPathMapping</servlet-name>
       <url-pattern>/authsec/*</url-pattern>
    </servlet-mapping>
-   
-      
+
    <!-- Asynchronous service request processor -->
    <servlet>
       <servlet-name>AjaxPortalEntryPoint</servlet-name>




More information about the portal-commits mailing list