portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r902971 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/ components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/ components/jetspeed-portal-site/src/test/ja...
Date Mon, 25 Jan 2010 20:55:39 GMT
Author: rwatler
Date: Mon Jan 25 20:55:39 2010
New Revision: 902971

URL: http://svn.apache.org/viewvc?rev=902971&view=rev
Log:
implement content type fallback for missing system, (*.psml), type pages

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteContentTypeMapper.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java?rev=902971&r1=902970&r2=902971&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteContentTypeMapperImpl.java
Mon Jan 25 20:55:39 2010
@@ -15,9 +15,10 @@
 public class PortalSiteContentTypeMapperImpl implements PortalSiteContentTypeMapper
 {
     public static final String DEFAULT_PAGE_SYSTEM_TYPE_SUFFIX = Page.DOCUMENT_TYPE;
-    
+
     private List<ContentTypeMapping> contentTypeMappings;
     private List<RequestPathMapping> requestPathMappings;
+    private boolean enableContentTypeFallback;
     
     /**
      * Construct default PortalSite content type mapper implementation.
@@ -34,7 +35,19 @@
      */
     public PortalSiteContentTypeMapperImpl(List<ContentTypeMapping> contentTypeMappings)
     {
-        this(contentTypeMappings, null);
+        this(contentTypeMappings, null, false);
+    }
+
+    /**
+     * Construct default PortalSite content type mapper implementation.
+     * 
+     * @param contentTypeMappings mappings to determine content type from request path
+     * @param enableContentTypeFallback enable content type fallback for missing system
+     *                                  type page, folder, etc. requests
+     */
+    public PortalSiteContentTypeMapperImpl(List<ContentTypeMapping> contentTypeMappings,
boolean enableContentTypeFallback)
+    {
+        this(contentTypeMappings, null, enableContentTypeFallback);
     }
 
     /**
@@ -46,8 +59,23 @@
      */
     public PortalSiteContentTypeMapperImpl(List<ContentTypeMapping> contentTypeMappings,
List<RequestPathMapping> requestPathMappings)
     {        
+        this(contentTypeMappings, requestPathMappings, false);
+    }
+
+    /**
+     * Construct default PortalSite content type mapper implementation.
+     * 
+     * @param contentTypeMappings mappings to determine content type from request path
+     * @param requestPathMappings mappings to determine request path from server name,
+     *                            content type, and request path
+     * @param enableContentTypeFallback enable content type fallback for missing system
+     *                                  type page, folder, etc. requests
+     */
+    public PortalSiteContentTypeMapperImpl(List<ContentTypeMapping> contentTypeMappings,
List<RequestPathMapping> requestPathMappings, boolean enableContentTypeFallback)
+    {        
         this.contentTypeMappings = contentTypeMappings;
         this.requestPathMappings = requestPathMappings;
+        this.enableContentTypeFallback = enableContentTypeFallback;
     }
 
     /* (non-Javadoc)
@@ -69,6 +97,14 @@
         }
         return null;
     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.portalsite.PortalSiteContentTypeMapper#isContentTypeFallbackEnabled()
+     */
+    public boolean isContentTypeFallbackEnabled()
+    {
+        return enableContentTypeFallback;
+    }
 
     /* (non-Javadoc)
      * @see org.apache.jetspeed.portalsite.PortalSiteContentTypeMapper#mapRequestPath(java.lang.String,
java.lang.String, java.lang.String)

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=902971&r1=902970&r2=902971&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
Mon Jan 25 20:55:39 2010
@@ -32,7 +32,6 @@
 import javax.servlet.http.HttpSessionEvent;
 
 import org.apache.jetspeed.om.folder.Folder;
-import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.page.DynamicPage;
 import org.apache.jetspeed.om.page.FragmentDefinition;
 import org.apache.jetspeed.om.page.BaseConcretePageElement;
@@ -262,6 +261,29 @@
                 // types matched, continue below with native portal resolution
                 // of request
                 String systemType = contentTypeMapper.mapSystemType(requestPath);
+                if ((systemType != null) && contentTypeMapper.isContentTypeFallbackEnabled())
+                {
+                    // test for exact system match if content fallback enabled;
+                    // clear system type if not found
+                    SiteView view = getSiteView();
+                    if (view != null)
+                    {
+                        try
+                        {
+                            view.getNodeProxy(requestPath, null, false, false);
+                        }
+                        catch (NodeNotFoundException nnfe)
+                        {
+                            // log fallback mapping
+                            if (log.isDebugEnabled())
+                            {
+                                log.debug("System request: requestPath="+requestPath+" does
not exist: fallback to content type");
+                            }                    
+                            systemType = null;
+                        }
+                    }
+                }
+                // if not system type, test for content type
                 if (systemType == null)
                 {
                     // test for content type mappings; if no content type matched

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml?rev=902971&r1=902970&r2=902971&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/JETSPEED-INF/spring/test-spring.xml
Mon Jan 25 20:55:39 2010
@@ -192,6 +192,7 @@
                </bean>
            </list>
        </constructor-arg>
+       <constructor-arg index="2"><value>true</value></constructor-arg>
   </bean>
   <bean id="org.apache.jetspeed.portalsite.PortalSite" 
        name="portalSite"

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java?rev=902971&r1=902970&r2=902971&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
Mon Jan 25 20:55:39 2010
@@ -1481,6 +1481,19 @@
         assertTrue(requestPageProxy instanceof DynamicPage);
         assertEquals("docpage.dpsml", requestPageProxy.getName());
         assertEquals("/contentfolder/pub/docpage.dpsml", extractFileSystemPathFromId(requestPageProxy.getId()));
+
+        locator = new JetspeedProfileLocator();
+        locator.init(null, "/document.psml");
+        locator.add("user", true, false, "user");
+        locators = new HashMap();
+        locators.put(ProfileLocator.PAGE_LOCATOR, locator);
+        requestContext = sessionContext.newRequestContext(locators);
+        assertNotNull(requestContext);
+        requestPageProxy = requestContext.getPage();
+        assertNotNull(requestPageProxy);
+        assertTrue(requestPageProxy instanceof DynamicPage);
+        assertEquals("contentpage.dpsml", requestPageProxy.getName());
+        assertEquals("/contentpage.dpsml", extractFileSystemPathFromId(requestPageProxy.getId()));
     }
 
     /**

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteContentTypeMapper.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteContentTypeMapper.java?rev=902971&r1=902970&r2=902971&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteContentTypeMapper.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteContentTypeMapper.java
Mon Jan 25 20:55:39 2010
@@ -38,6 +38,14 @@
     String mapSystemType(String requestPath);
 
     /**
+     * isContentTypeFallbackEnabled - enable content type fallback for missing
+     *                                system type page, folder, etc. requests
+     *
+     * @return content type fallback enabled flag
+     */
+    boolean isContentTypeFallbackEnabled();
+
+    /**
      * mapContentType - map request to content type used to select dynamic
      *                  pages; implementation should return null to handle
      *                  request as page and folder lookup.



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message