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 dd...@apache.org on 2006/01/06 22:33:31 UTC

svn commit: r366570 - in /portals/pluto/trunk: pluto-container/src/main/java/org/apache/pluto/core/impl/ pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ p...

Author: ddewolf
Date: Fri Jan  6 13:33:22 2006
New Revision: 366570

URL: http://svn.apache.org/viewcvs?rev=366570&view=rev
Log:
Defaulting configuration to memory based (not db based); Fixing PortletSession bug per spec

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
    portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java
    portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java
    portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java
    portals/pluto/trunk/pluto-portal/pom.xml
    portals/pluto/trunk/pluto-portal/src/assemble/bin.xml
    portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/pluto-portal-driver-services-config.xml

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletRequestImpl.java Fri Jan  6 13:33:22 2006
@@ -181,6 +181,9 @@
     }
 
     public PortletSession getPortletSession(boolean create) {
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("Retreiving portlet session (create="+create+")");
+        }
         //
         // It is critical that we don't retrieve the
         //    portlet session until the cross context
@@ -196,13 +199,26 @@
         }
 
         HttpSession http = getHttpServletRequest().getSession(create);
-        if (http != null && portletSession == null) {
+        // We must make sure that if the session
+        // has been invalidated (perhaps through setMaxIntervalTimeout())
+        // and the underlying request returns null that we no longer
+        // use the cached version.
+        //
+        if(http == null) {
+            if(LOG.isDebugEnabled()) {
+                LOG.debug("Underlying Http session is null; No session will be returned.");
+            }
+            return null;
+        }
+
+        if (portletSession == null) {
             portletSession = new PortletSessionImpl(
                     portletContext,
                     internalPortletWindow,
                     http
             );
         }
+
         return portletSession;
     }
 

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/impl/PortletSessionImpl.java Fri Jan  6 13:33:22 2006
@@ -100,9 +100,11 @@
     }
 
     public void setMaxInactiveInterval(int interval) {
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("Session timeout set to: "+interval);
+        }
         httpSession.setMaxInactiveInterval(interval);
     }
-
 
 //
 //

Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java Fri Jan  6 13:33:22 2006
@@ -18,6 +18,7 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.ArrayList;
 
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
@@ -162,6 +163,7 @@
     private static final String RENDER_PARAM = "rp";
     private static final String WINDOW_STATE = "ws";
     private static final String PORTLET_MODE = "pm";
+    private static final String VALUE_DELIM = "0x0";
 
     private static final String[][] ENCODINGS =
         new String[][]{
@@ -198,7 +200,7 @@
      * Parse a control parameter into the porlet which it effects and it's
      * original value.
      * @param ctl
-     * @return
+     * @return values
      */
     private String[] decode(String ctl) {
         int length = (PREFIX + PORTLET_ID).length();
@@ -223,11 +225,18 @@
         return vals;
     }
 
+    /**
+     * Decode a parameter
+     * @param name
+     * @param value
+     * @return url parameter
+     */
     private PortalUrlParameter decode(String name, String value) {
         String nopre = name.substring((PREFIX + PORTLET_ID).length());
         String windowId = nopre.substring(0, nopre.indexOf(DELIM));
         String param = nopre.substring(nopre.indexOf(DELIM) + 1);
 
+        ArrayList values = new ArrayList();
         for (int i = 0; i < ENCODINGS.length; i++) {
             windowId =
             StringUtils.replace(windowId, ENCODINGS[i][1], ENCODINGS[i][0]);
@@ -235,8 +244,14 @@
                 value =
                 StringUtils.replace(value, ENCODINGS[i][1], ENCODINGS[i][0]);
             }
+            int idx, start = 0;
+            while( (idx = value.indexOf(VALUE_DELIM, start)) > 0) {
+                values.add(value.substring(start, idx));
+                start = idx;
+            }
         }
-        return new PortalUrlParameter(windowId, param, value);
+        String[] vals = values.size() > 0 ? (String[])values.toArray(new String[values.size()]) : new String[] { value };
+        return new PortalUrlParameter(windowId, param, vals);
     }
 
     private String encode(String string) {
@@ -252,7 +267,7 @@
         for (int i = 0; i < strings.length; i++) {
             sb.append(strings[i]);
             if (i + 1 != strings.length) {
-                sb.append(",");
+                sb.append(VALUE_DELIM);
             }
         }
         return sb.toString();

Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java Fri Jan  6 13:33:22 2006
@@ -17,10 +17,17 @@
 
 import org.apache.pluto.driver.config.DriverConfigurationException;
 import org.apache.pluto.driver.services.portal.*;
+import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
+import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.core.PortletDescriptorRegistry;
 
 import javax.servlet.ServletContext;
 import java.util.List;
 import java.util.Set;
+import java.util.Iterator;
 import java.io.InputStream;
 
 /**
@@ -31,9 +38,11 @@
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @since Aug 10, 2005
  */
-public class PortletRegistryServiceImpl implements PortletRegistryService {
+public class PortletRegistryServiceImpl
+   implements PortletRegistryService, PortletRegistryAdminService {
 
     private ResourceConfig config;
+    private ServletContext servletContext;
 
     public PortletRegistryServiceImpl() {
         
@@ -45,6 +54,7 @@
      */
     public void init(ServletContext ctx) {
         try {
+            servletContext = ctx;
             InputStream in = ctx.getResourceAsStream(ResourceConfigReader.CONFIG_FILE);
             config = ResourceConfigReader.getFactory().parse(in);
         }
@@ -55,6 +65,7 @@
 
     public void destroy() throws DriverConfigurationException {
         config = null;
+        servletContext = null;
     }
 
 
@@ -74,4 +85,40 @@
         return config.getPortletWindowConfig(id);
     }
 
+    public void addPortletApplication(String contextPath)
+    throws DriverAdministrationException {
+        if(contextPath == null)
+            throw new IllegalArgumentException("Can not add servlet context 'null'.");
+
+        try {
+            PortletApplicationConfig app = new PortletApplicationConfig();
+            app.setContextPath(contextPath);
+
+            ServletContext portletContext = servletContext.getContext(contextPath);
+            if(portletContext == null) {
+                throw new DriverAdministrationException(
+                    "Unable to locate context: "+contextPath+
+                    ". Ensure that crossContext support is enabled and the portlet application has been deployed.");
+            }
+
+            PortletAppDD descriptor = getPortletDescriptor(portletContext);
+            Iterator it = descriptor.getPortlets().iterator();
+            while(it.hasNext()) {
+                PortletDD portlet = (PortletDD)it.next();
+                PortletWindowConfig config = new PortletWindowConfig();
+                config.setContextPath(contextPath);
+                config.setPortletName(portlet.getPortletName());
+                app.addPortlet(config);
+            }
+            config.addPortletApp(app);
+        }
+        catch(PortletContainerException pce) {
+            throw new DriverAdministrationException("Unable to retrieve portlet descriptor from new context location", pce);
+        }
+    }
+
+    private PortletAppDD getPortletDescriptor(ServletContext context)
+    throws PortletContainerException {
+        return PortletDescriptorRegistry.getRegistry().getPortletAppDD(context);
+    }
 }

Modified: portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java (original)
+++ portals/pluto/trunk/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java Fri Jan  6 13:33:22 2006
@@ -1,6 +1,7 @@
 package org.apache.pluto.driver.services.portal.admin;
 
 import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.config.DriverConfigurationException;
 
 /**
  *
@@ -11,7 +12,7 @@
  */
 public interface RenderConfigAdminService {
 
-    public void addPage(PageConfig config);
-
+    public void addPage(PageConfig config)
+        throws DriverConfigurationException;
 
 }

Modified: portals/pluto/trunk/pluto-portal/pom.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal/pom.xml?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal/pom.xml (original)
+++ portals/pluto/trunk/pluto-portal/pom.xml Fri Jan  6 13:33:22 2006
@@ -52,6 +52,19 @@
   <build>
     <finalName>pluto-portal</finalName>
     <plugins>
+
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+		<configuration>
+          <tasks>
+            <get src="http://archive.apache.org/dist/tomcat/tomcat-5/archive/v5.5.9/bin/jakarta-tomcat-5.5.9.tar.gz" 
+                 dest="target/tomcat.tar.gz"/>
+            <gunzip src="target/tomcat.tar.gz"/>
+            <untar src="target/tomcat.tar"/>
+		  </tasks>
+		</configuration>
+      </plugin>
+
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>

Modified: portals/pluto/trunk/pluto-portal/src/assemble/bin.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal/src/assemble/bin.xml?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/assemble/bin.xml (original)
+++ portals/pluto/trunk/pluto-portal/src/assemble/bin.xml Fri Jan  6 13:33:22 2006
@@ -27,12 +27,11 @@
     </fileSet>
 
     <fileSet>
-      <directory>/jakarta-tomcat-5.5.9</directory>
+      <directory>target/tomcat</directory>
       <outputDirectory></outputDirectory>
     </fileSet>
 
     <fileSet>
-    <!-- mvn site:site must be run first -->
       <directory>../pluto-site/target/site</directory>
 	  <outputDirectory>webapps/ROOT</outputDirectory>
     </fileSet>

Modified: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/pluto-portal-driver-services-config.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/pluto-portal-driver-services-config.xml?rev=366570&r1=366569&r2=366570&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/pluto-portal-driver-services-config.xml (original)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/pluto-portal-driver-services-config.xml Fri Jan  6 13:33:22 2006
@@ -9,23 +9,18 @@
   NOTE:
 
   The following configuration file contains the spring bean
-  configuration needed to run the pluto-portal with all the
-  bells and whistles.  This includes, but is not limited to,
-  database backed preferences and user-attributes.  Additionally
-  it supports advanced administration utilities (such as
-  portlet application publishing) to ease getting started
-  with pluto.
-
-  While these bells and whistles are nice, all of these functions
-  are not required.  A *very* lightweight implementation is provided
-  in comments below. This configuration provides memory based
-  services (instead of db ones).
-
-  In order to ease getting started, by default, the database
-  used is embedded within the portal and will be automatically
-  be created the FIRST TIME you startup pluto.  Once created,
-  your startup time should decreate significantly.
-
+  configuration needed to run the pluto-portal in memory
+  mode.  Optional services are available which allow
+  persistence to an rdbms, xml files, etc. . . however,
+  we strongly recomend that if you are looking at these
+  advanced features that you consider an enterprise portal
+  such as Apache Jetspeed.
+
+  Service Functions Include:
+   - Preference Persistence
+   - User Attribute Persistence
+   - Portlet Registry
+   - Page Registry
   ************************************************************
 
   -->
@@ -46,14 +41,21 @@
       <constructor-arg><ref local="PortalCallbackService"/></constructor-arg>
 
       <!--  Optional Container Services -->
+      <!--
       <property name="portletPreferencesService"><ref local="PortletPreferencesService"/></property>
+      <property name="userAttributeService"><ref local="UserAttributeService"/></property>
+      -->
     </bean>
 
+    <!-- ================================================ -->
+    <!-- The single top element of the administration tree -->
+    <!-- ================================================ -->
     <bean id="AdminConfiguration" class="org.apache.pluto.driver.config.impl.AdminConfigurationImpl">
       <property name="portletRegistryAdminService"><ref local="PortletRegistryConfig"/></property>
       <property name="renderConfigAdminService"><ref local="RenderConfigService"/></property>
     </bean>
 
+
     <!-- ================================================ -->
     <!-- Portal Services injected into the Configuration  -->
     <!-- ================================================ -->
@@ -63,9 +65,8 @@
     </bean>
 
     <bean id="PortletRegistryConfig"
-          class="org.apache.pluto.driver.services.impl.db.DBPortletRegistryService"
+          class="org.apache.pluto.driver.services.impl.resource.PortletRegistryServiceImpl"
           singleton="true">
-        <constructor-arg><ref local="DataSourceManager"/></constructor-arg>
     </bean>
 
     <bean id="RenderConfigService"
@@ -73,7 +74,6 @@
           singleton="true">
     </bean>
 
-
     <!-- ================================================ -->
     <!-- Container Services injected into  Configuration  -->
     <!-- ================================================ -->
@@ -82,77 +82,21 @@
           singleton="true">
     </bean>
 
-
-    <!-- ================================================ -->
-    <!-- = Optional Services injected into Configuration  -->
-    <!-- ================================================ -->
+   <!-- ================================================ -->
+   <!-- = Optional Services injected into Configuration  -->
+   <!-- ================================================ -->
+   <!--
    <bean id="PortletPreferencesService"
           class="org.apache.pluto.optional.db.preferences.DBPortletPreferencesService"
           singleton="true">
         <constructor-arg><ref local="DataSourceManager"/></constructor-arg>
    </bean>
 
-    <!-- ================================================ -->
-    <!-- = Nested Services needed for Portal and Container Services -->
-    <!-- ================================================ -->
-
-    <bean id="DataSourceManager"
-          class="org.apache.pluto.optional.db.common.EmbeddedDataSourceManager"
-          singleton="true">
-        <constructor-arg index="0"><value>databaseName=PLUTO_PORTAL_DRIVER;name=pluto_portal_driver;password=apachep0rtals;create=true</value></constructor-arg>
-    </bean>
-
-    <!-- Uncomment to utilize a JNDI bound DataSource instead of
-         the embedded database datasource.  You must ensure that
-         the schema is created before startup if you wish to use
-         this DataSourceManager
-    -->
-    <!--
-    <bean name="DataSourceManager"
-          class="org.apache.pluto.optional.db.support.JNDIDataSourceManager"
-          singleton="true">
-        <constructor-arg><value>plutoDB</value></constructor-arg>
-    </bean>
-    -->
-
-
-
-
-
-
-
-
-
-
-
-    <!-- =========================================== -->
-    <!-- ====== LIGTHWEIGHT CONFIGURATION  ========= -->
-    <!-- =========================================== -->
-
-    <!--
-
-      To utilize the lightweight configuration, comment out
-      all services defined above and uncomment the following.
-
-      NOTE: make sure that you don't comment out the DriverConfiguration
-      (top element);
-
-     -->
-
-    <!--
-    <bean id="PropertyConfigService"
-          class="org.apache.pluto.driver.services.impl.resource.PropertyConfigServiceImpl"
-          singleton="true">
-    </bean>
-
-    <bean name="PortletRegistryService"
-          class="org.apache.pluto.driver.services.impl.resource.PortletRegistryServiceImpl
-          singleton="true">
-    </bean>
-
-     <bean id="RenderConfigService"
-          class="org.apache.pluto.driver.services.impl.resource.RenderConfigServiceImpl"
-          singleton="true">
-    </bean>
+   <bean id="UserAttributeService"
+         class="org.apache.pluto.optional.resource.preferences.DBPortletPreferencesService"
+         singleton="true">
+       <constructor-arg><ref local="DataSourceManager"/></constructor-arg>
+   </bean>
    -->
+
 </beans>