You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2014/11/25 13:50:09 UTC

[04/19] portals-pluto git commit: Implemented Ajax Action support in Pluto server. sketched out Partial Action Support in driver servlet. Moved paPageState class from pluto-driver-impl to pluto-driver project

Implemented Ajax Action support in Pluto server. sketched out Partial Action Support in driver servlet. Moved paPageState class from pluto-driver-impl to pluto-driver project


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/ae450175
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/ae450175
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/ae450175

Branch: refs/heads/PortletHub
Commit: ae450175064ac8cecc76e9edc16f7d7ace711ed2
Parents: c86384d
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Nov 20 14:34:02 2014 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Nov 20 14:34:02 2014 +0100

----------------------------------------------------------------------
 .../org/apache/pluto/driver/util/PageState.java | 306 -------------------
 .../apache/pluto/driver/util/package-info.java  |  25 --
 .../pluto/driver/PortalDriverServlet.java       | 253 +++++++++------
 .../org/apache/pluto/driver/util/PageState.java | 306 +++++++++++++++++++
 .../apache/pluto/driver/util/package-info.java  |  25 ++
 5 files changed, 485 insertions(+), 430 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ae450175/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/PageState.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/PageState.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/PageState.java
deleted file mode 100644
index 61708f2..0000000
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/PageState.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-
-package org.apache.pluto.driver.util;
-
-import static java.util.logging.Level.*;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletURL;
-import javax.portlet.WindowState;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.pluto.driver.AttributeKeys;
-import org.apache.pluto.driver.config.DriverConfiguration;
-import org.apache.pluto.driver.core.PortalRequestContext;
-import org.apache.pluto.driver.services.portal.PageConfig;
-import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParameter;
-
-/**
- * @author Scott Nicklous
- * 
- * This is a utility class that collects all data needed by the portlet
- * hub in one location. The data is formatted appropriately for transmission to 
- * the client.
- *
- */
-public class PageState {
-   private static final String LOG_CLASS = PageState.class.getName();
-   private final Logger        LOGGER    = Logger.getLogger(LOG_CLASS);
-
-   private DriverConfiguration   drvrConfig;
-   private PageConfig            pageConfig;
-   private PortalRequestContext  portalRC;
-   private PortalURL             portalUrl;
-   private ServletContext        servletContext;
-   
-   /**
-    * Constructor. Access the classes containing the necessary data.
-    *  
-    * @param request
-    */
-   public PageState(HttpServletRequest request) {
-      portalRC = PortalRequestContext.getContext(request);
-      portalUrl = portalRC.getRequestedPortalURL(); 
-      drvrConfig = (DriverConfiguration) portalRC.getServletContext()
-            .getAttribute(AttributeKeys.DRIVER_CONFIG);
-      servletContext = portalRC.getServletContext();
-      pageConfig = portalUrl.getPageConfig(servletContext);
-   }
-   
-   /**
-    * Returns the portal URL parameters that are set on the current URL.
-    * 
-    * @return
-    */
-   public Collection<PortalURLParameter> getParameters() {
-      return portalUrl.getParameters();
-   }
-   
-   /**
-    * Returns the public render parameters set on the current URL.
-    * 
-    * @return
-    */
-   public Map<String, String[]> getPublicParameters() {
-      return portalUrl.getPublicParameters();
-   }
-   
-   /**
-    * Returns a collection containing the portlet IDs for the portlets on the page.
-    * 
-    * @return
-    */
-   public Collection<String> getPortletIds() {
-      return pageConfig.getPortletIds();
-   }
-   
-   /**
-    * Returns a Pluto namespace string for the input portlet ID.
-    * @param   portletId
-    * @return  namespace string for the portlet ID
-    */
-   public String getNameSpace(String portletId) {
-      StringBuffer ns = new StringBuffer("Pluto_");
-      for (int ii=0; ii < portletId.length(); ii++) {
-         if (Character.isJavaIdentifierPart(portletId.charAt(ii))) {
-            ns.append(portletId.charAt(ii));
-         } else {
-            ns.append("_");
-         }
-      }
-      ns.append("_");
-      return ns.toString();
-   }
-   
-   /**
-    * Returns the public render parameter names for the portlet ID as a set.
-    * @param   portletId  
-    * @return  Set of string public render parameter names
-    */
-   public Set<String> getPRPNames(String portletId) {
-      Set<String> prpnames = new HashSet<String>();
-      PortletConfig pc = null;
-
-      try {
-         pc = drvrConfig.getPortletConfig(portletId);
-         Enumeration<String> prps = pc.getPublicRenderParameterNames();
-         while (prps.hasMoreElements()) {
-            String prp = prps.nextElement();
-            prpnames.add(prp);
-         }
-      } catch (Exception e) {}
-      return prpnames;
-   }
-   
-   /**
-    * Returns the public render parameter names for the portlet ID as a 
-    * delimited string that can be used in a JSON array.
-    * @param   portletId  
-    * @return  Delimited string of public render parameter names
-    */
-   public String getPRPNamesAsString(String portletId) {
-      PortletConfig pc = null;
-      StringBuffer prpstring = new StringBuffer();;
-
-      String sep = "";
-      try {
-         pc = drvrConfig.getPortletConfig(portletId);
-         Enumeration<String> prps = pc.getPublicRenderParameterNames();
-         while (prps.hasMoreElements()) {
-            String prp = prps.nextElement();
-            prpstring.append(sep + "'" + prp + "'");
-            sep = ", ";
-         }
-      } catch (Exception e) {}
-      return prpstring.toString();
-   }
-   
-   
-   /**
-    * Returns the supported portlet mode names for the portlet ID as a 
-    * delimited string that can be used in a JSON array.
-    * @param   portletId  
-    * @return  Delimited string of portlet mode names
-    */
-   public String getPortletModesAsString(String portletId) {
-      StringBuffer pmstring = new StringBuffer();
-      try {
-         Set<PortletMode> allowedPMs = drvrConfig.getSupportedPortletModes(portletId);
-         String sep = "";
-         for (PortletMode pm : allowedPMs) {
-            pmstring.append(sep + "'" + pm.toString() + "'");
-            sep = ", ";
-         }
-      } catch (Exception e) {}
-      return pmstring.toString();
-   }
-   
-   
-   /**
-    * Returns the supported window state names for the portlet ID as a 
-    * delimited string that can be used in a JSON array.
-    * @param   portletId  
-    * @return  Delimited string of window state names
-    */
-   public String getWindowStatesAsString(String portletId) {
-      StringBuffer wsstring = new StringBuffer();
-      try {
-         Set<WindowState> allowedWSs = drvrConfig.getSupportedWindowStates(portletId, "text/html");
-         String sep = "";
-         for (WindowState ws : allowedWSs) {
-            wsstring.append(sep + "'" + ws.toString() + "'");
-            sep = ", ";
-         }
-      } catch (Exception e) {}
-      return wsstring.toString();
-   }
-   
-   /**
-    * Returns the current portlet mode for the portlet
-    * 
-    * @param portletId
-    * @return
-    */
-   public String getPortletMode(String portletId) {
-      return portalUrl.getPortletMode(portletId).toString();
-   }
-   
-   /**
-    * Returns the current window state for the portlet
-    * 
-    * @param portletId
-    * @return
-    */
-   public String getWindowState(String portletId) {
-      return portalUrl.getWindowState(portletId).toString();
-   }
-   
-   /**
-    * Returns a relative base base as needed by the portlet hub to generate
-    * URLs. Must be encoded by the caller.
-    * 
-    * @return
-    */
-   public String getUrlBase() {
-      StringBuffer ub = new StringBuffer();
-      ub.append(portalUrl.getServletPath().startsWith("/")?"":"/")
-        .append(portalUrl.getServletPath())
-        .append(portalUrl.getRenderPath());
-      return ub.toString();
-   }
-   
-   /**
-    * Returns the page state needed by the portlet hub as a JSON string suitable
-    * for transport to the client.
-    * 
-    * @return  JSON string representing the current page state
-    */
-   public String toJSONString() {
-      StringBuffer json = new StringBuffer(1024);
-      json.append("{\n");
-      
-      Collection<PortalURLParameter> pups = getParameters();
-      Map<String, String[]> pubparms = getPublicParameters();
-      
-      for (String pid : getPortletIds()) {
-         json.append("   '" + getNameSpace(pid) + "' : {\n");
-         json.append("      'state' : {\n");
-         json.append("         'parameters' : {\n");
-
-         // Add the portlet parameters
-         String c1 = "            '";
-         for (PortalURLParameter pup : pups){
-            if (pup.getWindowId().equals(pid)){
-               json.append(c1  + pup.getName() + "' : [");
-               String c2 = "";
-               for (String val : pup.getValues()) {
-                  json.append(c2 + " '" + val + "'");
-                  c2 = ",";
-               }
-               json.append("]");
-               c1 = ",\n            '";
-            }
-         }
-         
-         // Add the public render parameter values for this portlet
-         
-         Set<String> prpnames = getPRPNames(pid);
-         for (String prp : pubparms.keySet()) {
-            if (prpnames.contains(prp)) {
-               json.append(c1 + prp + "' : [");
-               String c2 = "";
-               for (String val : (String[])pubparms.get(prp)) {
-                  json.append(c2 + " '" + val + "'");
-                  c2 = ",";
-               }
-               json.append("]");
-               c1 = ",\n            '";
-            }
-         }
-
-         json.append("         }, \n");
-         json.append("         'portletMode' : '" + getPortletMode(pid) + "', \n");
-         json.append("         'windowState' : '" + getWindowState(pid) + "'\n");
-         json.append("      },\n");
-         json.append("      'pubParms' : [" + getPRPNamesAsString(pid) + "],\n");
-         json.append("      'allowedPM' : [" + getPortletModesAsString(pid) + "],\n");
-         json.append("      'allowedWS' : [" + getWindowStatesAsString(pid) + "],\n");
-         json.append("      'renderData' : {\n");
-         json.append("         'renderData' : null,\n");
-         json.append("         'mimeType' : \"text/plain\"\n");
-         json.append("      },\n");
-         json.append("      'urlpid' : '" + pid + "'\n");
-         json.append("   },\n");
-      }
-      
-      json.append("}");
-      return json.toString();
-   }
-}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ae450175/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/package-info.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/package-info.java b/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/package-info.java
deleted file mode 100644
index faa0d9b..0000000
--- a/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/util/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-/**
- * @author Scott Nicklous
- *
- * Package containing utility classes used by the impl, primarily for
- * providing the necessary server-side support for the client-side portlet hub.
- */
-package org.apache.pluto.driver.util;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ae450175/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
index 8535dc9..ce50b35 100644
--- a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
@@ -17,6 +17,7 @@
 package org.apache.pluto.driver;
 
 import java.io.IOException;
+import java.io.Writer;
 
 import javax.portlet.PortletException;
 import javax.servlet.RequestDispatcher;
@@ -35,6 +36,7 @@ import org.apache.pluto.driver.core.PortletWindowImpl;
 import org.apache.pluto.driver.services.portal.PageConfig;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.util.PageState;
 
 /**
  * The controller servlet used to drive the Portal Driver. All requests mapped
@@ -90,107 +92,160 @@ public class PortalDriverServlet extends HttpServlet {
      * @throws IOException  if an error occurs writing to the response.
      */
     public void doGet(HttpServletRequest request, HttpServletResponse response)
-    throws ServletException, IOException {
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Start of PortalDriverServlet.doGet() to process portlet request . . .");
-        }
+          throws ServletException, IOException {
+       if (LOG.isDebugEnabled()) {
+          LOG.debug("Start of PortalDriverServlet.doGet() to process portlet request . . .");
+       }
 
-        if ( contentType != "" ) {
-            response.setContentType( contentType );
-        }
+       if ( contentType != "" ) {
+          response.setContentType( contentType );
+       }
 
-        PortalRequestContext portalRequestContext =
-            new PortalRequestContext(getServletContext(), request, response);
-
-        PortalURL portalURL = null;
-        
-        try {
-        	portalURL = portalRequestContext.getRequestedPortalURL();
-        } catch(Exception ex) {
-        	String msg = "Cannot handle request for portal URL. Problem: "  + ex.getMessage();
-        	LOG.error(msg, ex);
-        	throw new ServletException(msg, ex);
-        }
-        String actionWindowId = portalURL.getActionWindow();
-        String resourceWindowId = portalURL.getResourceWindow();
-        
-        PortletWindowConfig actionWindowConfig = null;
-        PortletWindowConfig resourceWindowConfig = null;
-        
-		if (resourceWindowId != null){
-			resourceWindowConfig = PortletWindowConfig.fromId(resourceWindowId);
-		} else if(actionWindowId != null){
-			 actionWindowConfig = PortletWindowConfig.fromId(actionWindowId);
-		}
-
-        // Action window config will only exist if there is an action request.
-        if (actionWindowConfig != null) {
-            PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-            		actionWindowConfig, portalURL);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Processing action request for window: "
-                		+ portletWindow.getId().getStringId());
-            }
-            try {
-                container.doAction(portletWindow, request, response, true);
-            } catch (PortletContainerException ex) {
-            	LOG.error(ex.getMessage(), ex);
-                throw new ServletException(ex);
-            } catch (PortletException ex) {
-            	LOG.error(ex.getMessage(), ex);
-                throw new ServletException(ex);
-            }
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Action request processed.\n\n");
-            }
-        }
-        //Resource request
-        else if (resourceWindowConfig != null) {
-            PortletWindowImpl portletWindow = new PortletWindowImpl(container,
-                               resourceWindowConfig, portalURL);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Processing resource Serving request for window: "
-                               + portletWindow.getId().getStringId());
-            }
-            try {
-                container.doServeResource(portletWindow, request, response);
-            } catch (PortletContainerException ex) {
-            	LOG.error(ex.getMessage(), ex);
-                throw new ServletException(ex);
-            } catch (PortletException ex) {
-            	LOG.error(ex.getMessage(), ex);
-                throw new ServletException(ex);
-            }
-            if (LOG.isDebugEnabled()) {
-               LOG.debug("Resource serving request processed.\n\n");
-            }
-        }
-        // Otherwise (actionWindowConfig == null), handle the render request.
-        else {
-        	if (LOG.isDebugEnabled()) {
-        		LOG.debug("Processing render request.");
-        	}
-            PageConfig pageConfig = portalURL.getPageConfig(servletContext);
-            if (pageConfig == null)
-            {
-            	String renderPath = (portalURL == null ? "" : portalURL.getRenderPath());
-                String msg = "PageConfig for render path [" + renderPath + "] could not be found.";
-                LOG.error(msg);
-                throw new ServletException(msg);
-            }
-            
-            request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
-            String uri = (pageConfig.getUri() != null)
-            		? pageConfig.getUri() : DEFAULT_PAGE_URI;
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Dispatching to: " + uri);
-            }
-            RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
-            dispatcher.forward(request, response);
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug("Render request processed.\n\n");
-            }
-        }
+       PortalRequestContext portalRequestContext =
+             new PortalRequestContext(getServletContext(), request, response);
+
+       PortalURL portalURL = null;
+
+       try {
+          portalURL = portalRequestContext.getRequestedPortalURL();
+       } catch(Exception ex) {
+          String msg = "Cannot handle request for portal URL. Problem: "  + ex.getMessage();
+          LOG.error(msg, ex);
+          throw new ServletException(msg, ex);
+       }
+
+       String ajaxActionWindowId = portalURL.getAjaxActionWindow();
+       String partialActionWindowId = portalURL.getPartialActionWindow();
+       String actionWindowId = portalURL.getActionWindow();
+       String resourceWindowId = portalURL.getResourceWindow();
+
+       PortletWindowConfig windowConfig = null;
+
+       // Action window config will only exist if there is an action request.
+       if (actionWindowId != null) {
+          windowConfig = PortletWindowConfig.fromId(actionWindowId);
+          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
+                windowConfig, portalURL);
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Processing action request for window: "
+                   + portletWindow.getId().getStringId());
+          }
+          try {
+             container.doAction(portletWindow, request, response, true);
+          } catch (PortletContainerException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          } catch (PortletException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          }
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Action request processed.\n\n");
+          }
+       }
+       
+       // Ajax Action request
+       else if (ajaxActionWindowId != null) {
+          windowConfig = PortletWindowConfig.fromId(ajaxActionWindowId);
+          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
+                windowConfig, portalURL);
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Processing Ajax Action request for window: "
+                   + portletWindow.getId().getStringId());
+          }
+          try {
+             container.doAction(portletWindow, request, response, false);
+             PageState ps = new PageState(request);
+             Writer writer = response.getWriter();
+             String jsondata = ps.toJSONString();
+             LOG.debug("Ajax Action: returning new page state to client: " + jsondata);
+             writer.write(jsondata);
+          } catch (PortletContainerException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          } catch (PortletException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          }
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Ajax Action request processed.\n\n");
+          }
+       }
+       
+       // Partial Action request
+       else if (partialActionWindowId != null) {
+          windowConfig = PortletWindowConfig.fromId(partialActionWindowId);
+          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
+                windowConfig, portalURL);
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Processing Partial Action request for window: "
+                   + portletWindow.getId().getStringId());
+          }
+          try {
+             container.doAction(portletWindow, request, response, false);
+             // TO DO: make page state data available to portlet thru ResourceRequest
+             container.doServeResource(portletWindow, request, response);
+          } catch (PortletContainerException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          } catch (PortletException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          }
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Partial Action request processed.\n\n");
+          }
+       }
+       
+       //Resource request
+       else if (resourceWindowId != null) {
+          windowConfig = PortletWindowConfig.fromId(resourceWindowId);
+          PortletWindowImpl portletWindow = new PortletWindowImpl(container,
+                windowConfig, portalURL);
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Processing resource Serving request for window: "
+                   + portletWindow.getId().getStringId());
+          }
+          try {
+             container.doServeResource(portletWindow, request, response);
+          } catch (PortletContainerException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          } catch (PortletException ex) {
+             LOG.error(ex.getMessage(), ex);
+             throw new ServletException(ex);
+          }
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Resource serving request processed.\n\n");
+          }
+       }
+       
+       // Otherwise (actionWindowConfig == null), handle the render request.
+       else {
+          if (LOG.isDebugEnabled()) {
+             LOG.debug("Processing render request.");
+          }
+          PageConfig pageConfig = portalURL.getPageConfig(servletContext);
+          if (pageConfig == null)
+          {
+             String renderPath = (portalURL == null ? "" : portalURL.getRenderPath());
+             String msg = "PageConfig for render path [" + renderPath + "] could not be found.";
+             LOG.error(msg);
+             throw new ServletException(msg);
+          }
+
+          request.setAttribute(AttributeKeys.CURRENT_PAGE, pageConfig);
+          String uri = (pageConfig.getUri() != null)
+                ? pageConfig.getUri() : DEFAULT_PAGE_URI;
+                if (LOG.isDebugEnabled()) {
+                   LOG.debug("Dispatching to: " + uri);
+                }
+                RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
+                dispatcher.forward(request, response);
+                if (LOG.isDebugEnabled()) {
+                   LOG.debug("Render request processed.\n\n");
+                }
+       }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ae450175/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/PageState.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/PageState.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/PageState.java
new file mode 100644
index 0000000..61708f2
--- /dev/null
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/PageState.java
@@ -0,0 +1,306 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.pluto.driver.util;
+
+import static java.util.logging.Level.*;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletURL;
+import javax.portlet.WindowState;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.core.PortalRequestContext;
+import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURLParameter;
+
+/**
+ * @author Scott Nicklous
+ * 
+ * This is a utility class that collects all data needed by the portlet
+ * hub in one location. The data is formatted appropriately for transmission to 
+ * the client.
+ *
+ */
+public class PageState {
+   private static final String LOG_CLASS = PageState.class.getName();
+   private final Logger        LOGGER    = Logger.getLogger(LOG_CLASS);
+
+   private DriverConfiguration   drvrConfig;
+   private PageConfig            pageConfig;
+   private PortalRequestContext  portalRC;
+   private PortalURL             portalUrl;
+   private ServletContext        servletContext;
+   
+   /**
+    * Constructor. Access the classes containing the necessary data.
+    *  
+    * @param request
+    */
+   public PageState(HttpServletRequest request) {
+      portalRC = PortalRequestContext.getContext(request);
+      portalUrl = portalRC.getRequestedPortalURL(); 
+      drvrConfig = (DriverConfiguration) portalRC.getServletContext()
+            .getAttribute(AttributeKeys.DRIVER_CONFIG);
+      servletContext = portalRC.getServletContext();
+      pageConfig = portalUrl.getPageConfig(servletContext);
+   }
+   
+   /**
+    * Returns the portal URL parameters that are set on the current URL.
+    * 
+    * @return
+    */
+   public Collection<PortalURLParameter> getParameters() {
+      return portalUrl.getParameters();
+   }
+   
+   /**
+    * Returns the public render parameters set on the current URL.
+    * 
+    * @return
+    */
+   public Map<String, String[]> getPublicParameters() {
+      return portalUrl.getPublicParameters();
+   }
+   
+   /**
+    * Returns a collection containing the portlet IDs for the portlets on the page.
+    * 
+    * @return
+    */
+   public Collection<String> getPortletIds() {
+      return pageConfig.getPortletIds();
+   }
+   
+   /**
+    * Returns a Pluto namespace string for the input portlet ID.
+    * @param   portletId
+    * @return  namespace string for the portlet ID
+    */
+   public String getNameSpace(String portletId) {
+      StringBuffer ns = new StringBuffer("Pluto_");
+      for (int ii=0; ii < portletId.length(); ii++) {
+         if (Character.isJavaIdentifierPart(portletId.charAt(ii))) {
+            ns.append(portletId.charAt(ii));
+         } else {
+            ns.append("_");
+         }
+      }
+      ns.append("_");
+      return ns.toString();
+   }
+   
+   /**
+    * Returns the public render parameter names for the portlet ID as a set.
+    * @param   portletId  
+    * @return  Set of string public render parameter names
+    */
+   public Set<String> getPRPNames(String portletId) {
+      Set<String> prpnames = new HashSet<String>();
+      PortletConfig pc = null;
+
+      try {
+         pc = drvrConfig.getPortletConfig(portletId);
+         Enumeration<String> prps = pc.getPublicRenderParameterNames();
+         while (prps.hasMoreElements()) {
+            String prp = prps.nextElement();
+            prpnames.add(prp);
+         }
+      } catch (Exception e) {}
+      return prpnames;
+   }
+   
+   /**
+    * Returns the public render parameter names for the portlet ID as a 
+    * delimited string that can be used in a JSON array.
+    * @param   portletId  
+    * @return  Delimited string of public render parameter names
+    */
+   public String getPRPNamesAsString(String portletId) {
+      PortletConfig pc = null;
+      StringBuffer prpstring = new StringBuffer();;
+
+      String sep = "";
+      try {
+         pc = drvrConfig.getPortletConfig(portletId);
+         Enumeration<String> prps = pc.getPublicRenderParameterNames();
+         while (prps.hasMoreElements()) {
+            String prp = prps.nextElement();
+            prpstring.append(sep + "'" + prp + "'");
+            sep = ", ";
+         }
+      } catch (Exception e) {}
+      return prpstring.toString();
+   }
+   
+   
+   /**
+    * Returns the supported portlet mode names for the portlet ID as a 
+    * delimited string that can be used in a JSON array.
+    * @param   portletId  
+    * @return  Delimited string of portlet mode names
+    */
+   public String getPortletModesAsString(String portletId) {
+      StringBuffer pmstring = new StringBuffer();
+      try {
+         Set<PortletMode> allowedPMs = drvrConfig.getSupportedPortletModes(portletId);
+         String sep = "";
+         for (PortletMode pm : allowedPMs) {
+            pmstring.append(sep + "'" + pm.toString() + "'");
+            sep = ", ";
+         }
+      } catch (Exception e) {}
+      return pmstring.toString();
+   }
+   
+   
+   /**
+    * Returns the supported window state names for the portlet ID as a 
+    * delimited string that can be used in a JSON array.
+    * @param   portletId  
+    * @return  Delimited string of window state names
+    */
+   public String getWindowStatesAsString(String portletId) {
+      StringBuffer wsstring = new StringBuffer();
+      try {
+         Set<WindowState> allowedWSs = drvrConfig.getSupportedWindowStates(portletId, "text/html");
+         String sep = "";
+         for (WindowState ws : allowedWSs) {
+            wsstring.append(sep + "'" + ws.toString() + "'");
+            sep = ", ";
+         }
+      } catch (Exception e) {}
+      return wsstring.toString();
+   }
+   
+   /**
+    * Returns the current portlet mode for the portlet
+    * 
+    * @param portletId
+    * @return
+    */
+   public String getPortletMode(String portletId) {
+      return portalUrl.getPortletMode(portletId).toString();
+   }
+   
+   /**
+    * Returns the current window state for the portlet
+    * 
+    * @param portletId
+    * @return
+    */
+   public String getWindowState(String portletId) {
+      return portalUrl.getWindowState(portletId).toString();
+   }
+   
+   /**
+    * Returns a relative base base as needed by the portlet hub to generate
+    * URLs. Must be encoded by the caller.
+    * 
+    * @return
+    */
+   public String getUrlBase() {
+      StringBuffer ub = new StringBuffer();
+      ub.append(portalUrl.getServletPath().startsWith("/")?"":"/")
+        .append(portalUrl.getServletPath())
+        .append(portalUrl.getRenderPath());
+      return ub.toString();
+   }
+   
+   /**
+    * Returns the page state needed by the portlet hub as a JSON string suitable
+    * for transport to the client.
+    * 
+    * @return  JSON string representing the current page state
+    */
+   public String toJSONString() {
+      StringBuffer json = new StringBuffer(1024);
+      json.append("{\n");
+      
+      Collection<PortalURLParameter> pups = getParameters();
+      Map<String, String[]> pubparms = getPublicParameters();
+      
+      for (String pid : getPortletIds()) {
+         json.append("   '" + getNameSpace(pid) + "' : {\n");
+         json.append("      'state' : {\n");
+         json.append("         'parameters' : {\n");
+
+         // Add the portlet parameters
+         String c1 = "            '";
+         for (PortalURLParameter pup : pups){
+            if (pup.getWindowId().equals(pid)){
+               json.append(c1  + pup.getName() + "' : [");
+               String c2 = "";
+               for (String val : pup.getValues()) {
+                  json.append(c2 + " '" + val + "'");
+                  c2 = ",";
+               }
+               json.append("]");
+               c1 = ",\n            '";
+            }
+         }
+         
+         // Add the public render parameter values for this portlet
+         
+         Set<String> prpnames = getPRPNames(pid);
+         for (String prp : pubparms.keySet()) {
+            if (prpnames.contains(prp)) {
+               json.append(c1 + prp + "' : [");
+               String c2 = "";
+               for (String val : (String[])pubparms.get(prp)) {
+                  json.append(c2 + " '" + val + "'");
+                  c2 = ",";
+               }
+               json.append("]");
+               c1 = ",\n            '";
+            }
+         }
+
+         json.append("         }, \n");
+         json.append("         'portletMode' : '" + getPortletMode(pid) + "', \n");
+         json.append("         'windowState' : '" + getWindowState(pid) + "'\n");
+         json.append("      },\n");
+         json.append("      'pubParms' : [" + getPRPNamesAsString(pid) + "],\n");
+         json.append("      'allowedPM' : [" + getPortletModesAsString(pid) + "],\n");
+         json.append("      'allowedWS' : [" + getWindowStatesAsString(pid) + "],\n");
+         json.append("      'renderData' : {\n");
+         json.append("         'renderData' : null,\n");
+         json.append("         'mimeType' : \"text/plain\"\n");
+         json.append("      },\n");
+         json.append("      'urlpid' : '" + pid + "'\n");
+         json.append("   },\n");
+      }
+      
+      json.append("}");
+      return json.toString();
+   }
+}

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/ae450175/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/package-info.java
----------------------------------------------------------------------
diff --git a/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/package-info.java b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/package-info.java
new file mode 100644
index 0000000..faa0d9b
--- /dev/null
+++ b/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/package-info.java
@@ -0,0 +1,25 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * @author Scott Nicklous
+ *
+ * Package containing utility classes used by the impl, primarily for
+ * providing the necessary server-side support for the client-side portlet hub.
+ */
+package org.apache.pluto.driver.util;
\ No newline at end of file